From f0aa336e093c3bfd9ca6dff6f90e853ded34b77d Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 19 Nov 2020 13:43:48 +0700 Subject: [PATCH] only write headers with a length that fits into 2 bytes in fuzz test --- fuzzing/header/fuzz.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fuzzing/header/fuzz.go b/fuzzing/header/fuzz.go index d3d937d8..9b444349 100644 --- a/fuzzing/header/fuzz.go +++ b/fuzzing/header/fuzz.go @@ -48,6 +48,11 @@ func Fuzz(data []byte) int { return 0 } } + // We always use a 2-byte encoding for the Length field in Long Header packets. + // Serializing the header will fail when using a higher value. + if hdr.IsLongHeader && hdr.Length > 16383 { + return 1 + } b := &bytes.Buffer{} if err := extHdr.Write(b, version); err != nil { // We are able to parse packets with connection IDs longer than 20 bytes,