浏览代码

check for negative number of rows when parsing results frame

Chris Bannister 10 年之前
父节点
当前提交
c2d8f27013
共有 2 个文件被更改,包括 10 次插入0 次删除
  1. 4 0
      frame.go
  2. 6 0
      frame_test.go

+ 4 - 0
frame.go

@@ -779,6 +779,10 @@ func (f *framer) parseResultRows() frame {
 	meta := f.parseResultMetadata()
 
 	numRows := f.readInt()
+	if numRows < 0 {
+		panic(fmt.Errorf("invalid row_count in result frame: %d", numRows))
+	}
+
 	colCount := len(meta.columns)
 
 	rows := make([][][]byte, numRows)

+ 6 - 0
frame_test.go

@@ -13,6 +13,12 @@ func TestFuzzBugs(t *testing.T) {
 		[]byte("\x8000\x0e\x00\x00\x00\x000"),
 		[]byte("\x8000\x00\x00\x00\x00\t0000000000"),
 		[]byte("\xa0\xff\x01\xae\xefqE\xf2\x1a"),
+		[]byte("\x8200\b\x00\x00\x00c\x00\x00\x00\x02000\x01\x00\x00\x00\x03" +
+			"\x00\n0000000000\x00\x14000000" +
+			"00000000000000\x00\x020000" +
+			"\x00\a000000000\x00\x050000000" +
+			"\xff0000000000000000000" +
+			"0000000"),
 	}
 
 	for i, test := range tests {