diff --git a/projects/golang/Dockerfile b/projects/golang/Dockerfile index 3cec4a181..337bdecec 100644 --- a/projects/golang/Dockerfile +++ b/projects/golang/Dockerfile @@ -34,7 +34,7 @@ COPY build.sh text_fuzzer.go \ ecdsa_fuzzer.go \ aes_fuzzer.go \ h2c_fuzzer.go \ - fuzz_h2c.options \ + fuzz_x_h2c.options \ elf_fuzzer.go \ tiff_fuzzer.go \ fuzz_tiff_decode.options \ diff --git a/projects/golang/build.sh b/projects/golang/build.sh index 1437581dd..56b3b6f4e 100755 --- a/projects/golang/build.sh +++ b/projects/golang/build.sh @@ -116,7 +116,7 @@ cd $SRC/net/http2/h2c cd $SRC/instrumentation && go run main.go $SRC/net && cd - go mod tidy -e -go=1.16 && go mod tidy -e -go=1.17 compile_go_fuzzer . FuzzH2c fuzz_x_h2c -mv $SRC/fuzz_h2c.options $OUT/ +mv $SRC/fuzz_x_h2c.options $OUT/ cp $SRC/openpgp_fuzzer.go $SRC/crypto/openpgp/packet cd $SRC/crypto/openpgp/packet @@ -214,4 +214,4 @@ compile_fuzzers "_latest_master" # options files cp $SRC/glob_fuzzer.options $OUT/ -cp $SRC/glob_fuzzer.options $OUT/glob_fuzzer_latest_master.options \ No newline at end of file +cp $SRC/glob_fuzzer.options $OUT/glob_fuzzer_latest_master.options diff --git a/projects/golang/fuzz_h2c.options b/projects/golang/fuzz_x_h2c.options similarity index 100% rename from projects/golang/fuzz_h2c.options rename to projects/golang/fuzz_x_h2c.options diff --git a/projects/golang/h2c_fuzzer.go b/projects/golang/h2c_fuzzer.go index 3f6fdb43e..6851b503f 100644 --- a/projects/golang/h2c_fuzzer.go +++ b/projects/golang/h2c_fuzzer.go @@ -18,14 +18,13 @@ package h2c import ( "bufio" "bytes" + "context" "fmt" "golang.org/x/net/http2" - "io" "io/ioutil" "net" "net/http" "net/textproto" - "net/url" "runtime" "strings" ) @@ -93,9 +92,9 @@ func FuzzH2c(data []byte) int { } h := NewHandler(handler, h2s) w := &FakeHttpWriter{} - r := &http.Request{ - Body: io.NopCloser(bytes.NewReader(data)), - URL: &url.URL{Path: "nil"}, + r, err := http.NewRequestWithContext(context.Background(), "PUT", "nil", bytes.NewReader(data)) + if err != nil { + return -1 } r.Header = headerMap defer catchPanics()