浏览代码

Merge pull request #409 from Zariel/fuzz-slice-bounds-range

fix reading short bytes not checking for enough bytes in the buffer
Chris Bannister 10 年之前
父节点
当前提交
ff9b40ce01
共有 2 个文件被更改,包括 4 次插入0 次删除
  1. 3 0
      frame.go
  2. 1 0
      frame_test.go

+ 3 - 0
frame.go

@@ -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])

+ 1 - 0
frame_test.go

@@ -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 {