You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/11/18 22:19:50 UTC
[2/3] thrift git commit: THRIFT-2839 TFramedTransport read bug
Client: Go Patch: Chi Vinh Le
THRIFT-2839 TFramedTransport read bug
Client: Go
Patch: Chi Vinh Le <cv...@chinet.info>
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/0dd4801c
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/0dd4801c
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/0dd4801c
Branch: refs/heads/master
Commit: 0dd4801ce5cd45ca076b1c716fa6f94f418731a2
Parents: 2f971e8
Author: Jens Geyer <je...@apache.org>
Authored: Tue Nov 18 21:55:30 2014 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Tue Nov 18 22:18:13 2014 +0100
----------------------------------------------------------------------
lib/go/thrift/framed_transport.go | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/0dd4801c/lib/go/thrift/framed_transport.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/framed_transport.go b/lib/go/thrift/framed_transport.go
index bfecbe8..21c636d 100644
--- a/lib/go/thrift/framed_transport.go
+++ b/lib/go/thrift/framed_transport.go
@@ -79,7 +79,14 @@ func (p *TFramedTransport) Read(buf []byte) (l int, err error) {
}
}
if p.frameSize < len(buf) {
- return 0, NewTTransportExceptionFromError(fmt.Errorf("Not enought frame size %d to read %d bytes", p.frameSize, len(buf)))
+ frameSize := p.frameSize
+ tmp := make([]byte, p.frameSize)
+ l, err = p.Read(tmp)
+ copy(buf, tmp)
+ if err == nil {
+ err = NewTTransportExceptionFromError(fmt.Errorf("Not enough frame size %d to read %d bytes", frameSize, len(buf)))
+ return
+ }
}
got, err := p.reader.Read(buf)
p.frameSize = p.frameSize - got
@@ -98,7 +105,7 @@ func (p *TFramedTransport) ReadByte() (c byte, err error) {
}
}
if p.frameSize < 1 {
- return 0, NewTTransportExceptionFromError(fmt.Errorf("Not enought frame size %d to read %d bytes", p.frameSize, 1))
+ return 0, NewTTransportExceptionFromError(fmt.Errorf("Not enough frame size %d to read %d bytes", p.frameSize, 1))
}
c, err = p.reader.ReadByte()
if err == nil {