golang: modify h2c fuzzer (#8604)

The fuzzer triggers this crash,
https://oss-fuzz.com/testcase-detail/5149758935400448, which I cannot
reproduce locally. This PR is an attempt to fix it.
Signed-off-by: AdamKorcz <adam@adalogics.com>

Signed-off-by: AdamKorcz <adam@adalogics.com>
This commit is contained in:
AdamKorcz 2022-09-27 16:42:49 +01:00 committed by GitHub
parent 24c4df9e1c
commit d9768e8aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import (
"net" "net"
"net/http" "net/http"
"net/textproto" "net/textproto"
"net/url"
"runtime" "runtime"
"strings" "strings"
) )
@ -97,6 +98,11 @@ func FuzzH2c(data []byte) int {
return -1 return -1
} }
r.Header = headerMap r.Header = headerMap
u, err := url.Parse("http://localhost:8001")
if err != nil {
return 0
}
r.URL = u
defer catchPanics() defer catchPanics()
h.ServeHTTP(w, r) h.ServeHTTP(w, r)
return 1 return 1