diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2023-07-20 10:41:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-20 10:41:19 +0100 |
commit | 62a3d49e6e91a1b44fcfd48242c5ace47e5a8b96 (patch) | |
tree | 8af375902b6ba78a1e403c9826a63163dd395e56 /dhcpv4/fuzz.go | |
parent | 5bd60b59380c32813c0ada2a119fe602ec6fd5bf (diff) | |
parent | 5648422c16cd75ffbe2c0c792a11badae15ab5e9 (diff) |
Merge branch 'master' into fix-out-of-bounds-read
Diffstat (limited to 'dhcpv4/fuzz.go')
-rw-r--r-- | dhcpv4/fuzz.go | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/dhcpv4/fuzz.go b/dhcpv4/fuzz.go deleted file mode 100644 index cf62ba5..0000000 --- a/dhcpv4/fuzz.go +++ /dev/null @@ -1,41 +0,0 @@ -// +build gofuzz - -package dhcpv4 - -import ( - "fmt" - "reflect" -) - -// Fuzz is the entrypoint for go-fuzz -func Fuzz(data []byte) int { - msg, err := FromBytes(data) - if err != nil { - return 0 - } - - serialized := msg.ToBytes() - - // Compared to dhcpv6, dhcpv4 has padding and fixed-size fields containing - // variable-length data; We can't expect the library to output byte-for-byte - // identical packets after a round-trip. - // Instead, we check that after a round-trip, the packet reserializes to the - // same internal representation - rtMsg, err := FromBytes(serialized) - - if err != nil || !reflect.DeepEqual(msg, rtMsg) { - fmt.Printf("Input: %x\n", data) - fmt.Printf("Round-trip: %x\n", serialized) - fmt.Println("Message: ", msg.Summary()) - fmt.Printf("Go repr: %#v\n", msg) - fmt.Println("Reserialized: ", rtMsg.Summary()) - fmt.Printf("Go repr: %#v\n", rtMsg) - if err != nil { - fmt.Printf("Got error while reserializing: %v\n", err) - panic("round-trip error: " + err.Error()) - } - panic("round-trip different: " + msg.Summary()) - } - - return 1 -} |