Explorar o código

ensure columnCount is not negative

Found using gofuzz
Chris Bannister %!s(int64=10) %!d(string=hai) anos
pai
achega
ad3a9ca8a6
Modificáronse 2 ficheiros con 7 adicións e 0 borrados
  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 {