Skip to content

Commit

Permalink
add handling of corner case (#1117)
Browse files Browse the repository at this point in the history
  • Loading branch information
olejkavn authored and sriv committed Jul 20, 2018
1 parent e62f840 commit 69b8239
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion conn/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func readResponse(conn net.Conn) ([]byte, error) {

buffer.Write(data[0:n])
messageLength, bytesRead := proto.DecodeVarint(buffer.Bytes())
if messageLength > 0 && messageLength < uint64(buffer.Len()) {
if (messageLength > 0 && messageLength < uint64(buffer.Len())) && ((messageLength + uint64(bytesRead)) <= uint64(buffer.Len())) {
return buffer.Bytes()[bytesRead : messageLength+uint64(bytesRead)], nil
}
}
Expand Down

0 comments on commit 69b8239

Please sign in to comment.