1
0
mirror of https://github.com/golang/go synced 2024-11-08 01:56:14 -07:00
go/misc/cgo/testsanitizers/testdata/libfuzzer1.go
Cherry Mui e870de9936 misc/cgo/testsanitizers: add libfuzzer tests
Apparently we don't have tests for libfuzzer mode. Add some tests.

Updates #57449.

Change-Id: I813da3e71c6d6f15db31914b248db220b0b7041e
Reviewed-on: https://go-review.googlesource.com/c/go/+/459555
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-12-27 21:10:04 +00:00

17 lines
321 B
Go

package main
import "C"
import "unsafe"
//export LLVMFuzzerTestOneInput
func LLVMFuzzerTestOneInput(p unsafe.Pointer, sz C.int) C.int {
b := C.GoBytes(p, sz)
if len(b) >= 6 && b[0] == 'F' && b[1] == 'u' && b[2] == 'z' && b[3] == 'z' && b[4] == 'M' && b[5] == 'e' {
panic("found it")
}
return 0
}
func main() {}