Skip to content

Commit

Permalink
[inet6] make ICMPv6NDOptUnknown a bit more fuzzable (#4305)
Browse files Browse the repository at this point in the history
Without this patch the type of Neighbor Discovery options generated by
fuzz(ICMPv6NDOptUnknown()) is always 0. With this patch applied option
types are random.

It's a follow-up to #4233
  • Loading branch information
evverx committed Mar 1, 2024
1 parent d8d24da commit 28c2f78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scapy/layers/inet6.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ def m2i(self, pkt, x):

class ICMPv6NDOptUnknown(_ICMPv6NDGuessPayload, Packet):
name = "ICMPv6 Neighbor Discovery Option - Scapy Unimplemented"
fields_desc = [ByteField("type", None),
fields_desc = [ByteField("type", 0),
FieldLenField("len", None, length_of="data", fmt="B",
adjust=lambda pkt, x: (2 + x) // 8),
ICMPv6NDOptDataField("data", "", strip_zeros=False,
Expand Down
2 changes: 2 additions & 0 deletions test/scapy/layers/inet6.uts
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,8 @@ assert raw(p) == b
p = ICMPv6NDOptSrcLLAddr(b)[ICMPv6NDOptUnknown]
assert p.type == 0 and p.len == 2 and p.data == b'somestring\x00\x00\x00\x00'

= ICMPv6NDOptUnknown - fuzz
assert isinstance(fuzz(ICMPv6NDOptUnknown()).type, RandByte)

############
############
Expand Down

0 comments on commit 28c2f78

Please sign in to comment.