Skip to content

Commit 5a1f68f

Browse files
Avoid fuzz() messing up default_fields (#4705)
1 parent 23b1628 commit 5a1f68f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scapy/packet.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2937,7 +2937,12 @@ def fuzz(p, # type: _P
29372937
rnd = fld._find_fld_pkt(q).randval()
29382938
if rnd is not None:
29392939
new_default_fields[name] = rnd
2940-
q.default_fields.update(new_default_fields)
2940+
# Avoid messing up the original packet `default_fields` dictionary which is unique for all instances of the given layer.
2941+
# Build a new dictionary, and update it with `new_default_fields`.
2942+
q.default_fields = {
2943+
**q.default_fields,
2944+
**new_default_fields,
2945+
}
29412946
q = q.payload
29422947

29432948
# Avoid caching for `p`.

0 commit comments

Comments
 (0)