浏览代码

crypto/bn256: fix bn256Mul fuzzer to not hang on large input (#21872)

* crypto/bn256: fix bn256Mul fuzzer to not hang on large input

* Update crypto/bn256/bn256_fuzz.go

Co-authored-by: ligi <ligi@ligi.de>

Co-authored-by: ligi <ligi@ligi.de>
Martin Holst Swende 5 年之前
父节点
当前提交
ebb9591c4d
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      crypto/bn256/bn256_fuzz.go

+ 6 - 0
crypto/bn256/bn256_fuzz.go

@@ -80,6 +80,12 @@ func FuzzMul(data []byte) int {
 	if remaining == 0 {
 		return 0
 	}
+	if remaining > 128 {
+		// The evm only ever uses 32 byte integers, we need to cap this otherwise
+		// we run into slow exec. A 236Kb byte integer cause oss-fuzz to report it as slow.
+		// 128 bytes should be fine though
+		return 0
+	}
 	buf := make([]byte, remaining)
 	input.Read(buf)