Skip to content

Commit

Permalink
fix reading short bytes not checking for enough bytes in the buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel committed Jun 12, 2015
1 parent df14309 commit 9db0f56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,9 @@ func (f *framer) readBytes() []byte {

func (f *framer) readShortBytes() []byte {
size := f.readShort()
if len(f.rbuf) < int(size) {
panic(fmt.Errorf("not enough bytes in buffer to read short bytes: require %d got %d", size, len(f.rbuf)))
}

l := make([]byte, size)
copy(l, f.rbuf[:size])
Expand Down
1 change: 1 addition & 0 deletions frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestFuzzBugs(t *testing.T) {
"\xff0000000000000000000" +
"0000000"),
[]byte("\x82\xe600\x00\x00\x00\x000"),
[]byte("\x8200\b\x00\x00\x00\b0\x00\x00\x00\x040000"),
}

for i, test := range tests {
Expand Down

0 comments on commit 9db0f56

Please sign in to comment.