瀏覽代碼

ensure columnCount is not negative

Found using gofuzz
Chris Bannister 10 年之前
父節點
當前提交
ad3a9ca8a6
共有 2 個文件被更改,包括 7 次插入0 次删除
  1. 3 0
      frame.go
  2. 4 0
      frame_test.go

+ 3 - 0
frame.go

@@ -732,6 +732,9 @@ func (f *framer) parseResultMetadata() resultMetadata {
 	}
 
 	colCount := f.readInt()
+	if colCount < 0 {
+		panic(fmt.Errorf("received negative column count: %d", colCount))
+	}
 	meta.actualColCount = colCount
 
 	if meta.flags&flagHasMorePages == flagHasMorePages {

+ 4 - 0
frame_test.go

@@ -25,6 +25,10 @@ func TestFuzzBugs(t *testing.T) {
 			"00000"),
 		[]byte("\x83000\b\x00\x00\x00\x14\x00\x00\x00\x020000000" +
 			"000000000"),
+		[]byte("\x83000\b\x00\x00\x000\x00\x00\x00\x04\x00\x1000000" +
+			"00000000000000e00000" +
+			"000\x800000000000000000" +
+			"0000000000000"),
 	}
 
 	for i, test := range tests {