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 /dhcpv6 | |
parent | 5bd60b59380c32813c0ada2a119fe602ec6fd5bf (diff) | |
parent | 5648422c16cd75ffbe2c0c792a11badae15ab5e9 (diff) |
Merge branch 'master' into fix-out-of-bounds-read
Diffstat (limited to 'dhcpv6')
-rw-r--r-- | dhcpv6/dhcpv6_test.go | 36 | ||||
-rw-r--r-- | dhcpv6/fuzz.go | 33 |
2 files changed, 36 insertions, 33 deletions
diff --git a/dhcpv6/dhcpv6_test.go b/dhcpv6/dhcpv6_test.go index 210f19d..9ea61fa 100644 --- a/dhcpv6/dhcpv6_test.go +++ b/dhcpv6/dhcpv6_test.go @@ -273,3 +273,39 @@ func TestGetTransactionIDRelay(t *testing.T) { // TODO test NewMessageTypeSolicit // test String and Summary + +func FuzzDHCPv6(f *testing.F) { + + var relayForwBytesDuidUUID_data = []byte{ + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x26, 0x8a, 0x07, 0xff, 0xfe, 0x56, + 0xdc, 0xa4, 0x00, 0x12, 0x00, 0x06, 0x24, 0x8a, + 0x07, 0x56, 0xdc, 0xa4, 0x00, 0x09, 0x00, 0x5a, + 0x06, 0x7d, 0x9b, 0xca, 0x00, 0x01, 0x00, 0x12, + 0x00, 0x04, 0xb7, 0xfd, 0x0a, 0x8c, 0x1b, 0x14, + 0x10, 0xaa, 0xeb, 0x0a, 0x5b, 0x3f, 0xe8, 0x9d, + 0x0f, 0x56, 0x00, 0x06, 0x00, 0x0a, 0x00, 0x17, + 0x00, 0x18, 0x00, 0x17, 0x00, 0x18, 0x00, 0x01, + 0x00, 0x08, 0x00, 0x02, 0xff, 0xff, 0x00, 0x03, + 0x00, 0x28, 0x07, 0x56, 0xdc, 0xa4, 0x00, 0x00, + 0x0e, 0x10, 0x00, 0x00, 0x15, 0x18, 0x00, 0x05, + 0x00, 0x18, 0x26, 0x20, 0x01, 0x0d, 0xc0, 0x82, + 0x90, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xaf, 0xa0, 0x00, 0x00, 0x1c, 0x20, 0x00, 0x00, + 0x1d, 0x4c} + + f.Add(relayForwBytesDuidUUID_data) + f.Add([]byte{01, 0xab, 0xcd, 0xef, 0x00, 0x00, 0x00, 0x00}) + f.Add([]byte{01, 0xa, 0xb, 0xc, 0x00, 0x00, 0x00, 0x00}) + f.Add([]byte("0000\x00\x01\x00\x0e\x00\x01000000000000")) + + f.Fuzz(func(t *testing.T, data []byte) { + msg, err := FromBytes(data) + if err != nil { + return + } + msg.ToBytes() + }) +} diff --git a/dhcpv6/fuzz.go b/dhcpv6/fuzz.go deleted file mode 100644 index 3f5afef..0000000 --- a/dhcpv6/fuzz.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build gofuzz - -package dhcpv6 - -import ( - "bytes" - "fmt" -) - -// Fuzz is an entrypoint for go-fuzz (github.com/dvyukov/go-fuzz) -func Fuzz(data []byte) int { - msg, err := FromBytes(data) - if err != nil { - return 0 - } - - serialized := msg.ToBytes() - if !bytes.Equal(data, serialized) { - rtMsg, err := FromBytes(serialized) - 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("round-trip reserialized: ", rtMsg.Summary()) - fmt.Printf("Go repr: %#v\n", rtMsg) - if err != nil { - fmt.Printf("failed to parse after deserialize-serialize: %v\n", err) - } - panic("round-trip different") - } - - return 1 -} |