Merge pull request #694 from guedou/Issue_#529

Don't call randval() on unused ConditionalField
This commit is contained in:
Pierre Lalet 2017-07-20 14:45:17 +02:00 committed by GitHub
commit a8decd0518
2 changed files with 5 additions and 4 deletions

View File

@ -1463,9 +1463,10 @@ def fuzz(p, _inplace=0):
print("fuzzing", repr(r))
fuzz(r, _inplace=1)
elif f.default is not None:
rnd = f.randval()
if rnd is not None:
q.default_fields[f.name] = rnd
if not isinstance(f, ConditionalField) or f._evalcond(q):
rnd = f.randval()
if rnd is not None:
q.default_fields[f.name] = rnd
q = q.payload
return p

View File

@ -403,7 +403,7 @@ bind_layers(IP, ICMP, frag=0, proto=1)
= fuzz
~ not_pypy
random.seed(0x2807)
str(fuzz(IP()/ICMP())) == '\xe5S\x00\x1c\x9dC \x007\x01(H\x7f\x00\x00\x01\x7f\x00\x00\x01*\xdb\xf7,9\x8e\xa4i'
str(fuzz(IP()/ICMP())) == 'u\x14\x00\x1c\xc2\xf6\x80\x00\xde\x01k\xd3\x7f\x00\x00\x01\x7f\x00\x00\x01y\xc9>\xa6\x84\xd8\xc2\xb7'
= Building some packets
~ basic IP TCP UDP NTP LLC SNAP Dot11