fishy commented on a change in pull request #2292:
URL: https://github.com/apache/thrift/pull/2292#discussion_r540585807
##########
File path: lib/go/thrift/binary_protocol.go
##########
@@ -482,35 +480,37 @@ func (p *TBinaryProtocol) readAll(ctx context.Context,
buf []byte) (err error) {
const readLimit = 32768
func (p *TBinaryProtocol) readStringBody(size int32) (value string, err error)
{
+ buf, err := safeReadBytes(size, p.trans, p.buffer[:], readLimit)
+ return buf.String(), NewTProtocolException(err)
+}
+
+// This function is shared between TBinaryProtocol and TCompactProtocol.
+func safeReadBytes(size int32, trans io.Reader, buffer []byte, singleReadLimit
int) (*bytes.Buffer, error) {
Review comment:
Good point. Actually we don't need to specify the limit at all.
Combining bytes.Buffer with io.CopyN is enough.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]