Skip to content

Commit

Permalink
internal/fuzz: update to use native go-fuzz
Browse files Browse the repository at this point in the history
Fixes golang/protobuf#1084.

Change-Id: I2c71e9f58d09345d13f461ec78ee4e39c3a7f06d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/228277
Reviewed-by: Joe Tsai <joetsai@google.com>
  • Loading branch information
neild committed Apr 15, 2020
1 parent 5e85542 commit d8bc21f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions internal/fuzz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Fuzzing support using [go-fuzz](https://github.com/dvyukov/go-fuzz).
Basic operation:

```sh
$ go install github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
$ go install github.com/dvyukov/go-fuzz/go-fuzz
$ go install github.com/mdempsky/go114-fuzz-build
$ cd internal/fuzz/{fuzzer}
$ GOFUZZ111MODULE=on go-fuzz-build .
$ go114-fuzz-build google.golang.org/protobuf/internal/fuzz/{fuzzer}
$ go-fuzz
```

Expand Down
4 changes: 2 additions & 2 deletions internal/fuzz/oss-fuzz-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function compile_fuzzer {
fuzzer=$3

# Instrument all Go files relevant to this fuzzer
go-fuzz-build -tags=protolegacy -libfuzzer -func $function -o $fuzzer.a $path
go-fuzz -tags=protolegacy -func $function -o $fuzzer.a $path

# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
Expand All @@ -19,7 +19,7 @@ function compile_fuzzer {
for x in internal/fuzz/*; do
if [ -d $x/corpus ]; then
name=$(basename $x)
compile_fuzzer ./$x Fuzz $name
compile_fuzzer google.golang.org/protobuf/$x Fuzz $name
zip -jr $OUT/${name}_seed_corpus.zip $x/corpus
fi
done

0 comments on commit d8bc21f

Please sign in to comment.