Skip to content

Commit 0e88e8f

Browse files
guedougpotter2
authored andcommitted
hexdiff() - check input length
1 parent 5370ef2 commit 0e88e8f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

scapy/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def hexdiff(a, b, autojunk=False):
455455

456456
cl = ""
457457
for j in range(16):
458-
if i + j < btx_len:
458+
if i + j < min(len(backtrackx), len(backtracky)):
459459
if line[j]:
460460
col = colorize[(linex[j] != liney[j]) * (doy - dox)]
461461
print(col("%02X" % orb(line[j])), end=' ')

test/regression.uts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,11 @@ assert ret1 != ret2
772772
assert expected_ret1 in ret1
773773
assert expected_ret2 in ret2
774774

775+
# Test corner cases that should not crash
776+
777+
hexdiff(b"abc", IP() / TCP())
778+
hexdiff(IP() / TCP(), b"abc")
779+
775780
= Test mysummary functions - Ether
776781

777782
p = Ether(dst="ff:ff:ff:ff:ff:ff", src="ff:ff:ff:ff:ff:ff", type=0x9000)

0 commit comments

Comments
 (0)