Skip to content

Commit 140ba64

Browse files
author
Kelvin Estrada
committed
Fix IP.Summary() crash when dst is RandIP()
1 parent 40fc5ec commit 140ba64

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

scapy/layers/inet.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ def route(self):
586586
if conf.route is None:
587587
# unused import, only to initialize conf.route
588588
import scapy.route # noqa: F401
589+
if not isinstance(dst, (str, bytes, int)):
590+
dst = str(dst)
589591
return conf.route.route(dst, dev=scope)
590592

591593
def hashret(self):

test/scapy/layers/inet.uts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ pkts = sniff(offline=pkts, session=IPSession)
9292
assert len(pkts) == 2
9393
assert pkts[1].load == b"X" * 1500
9494

95+
= IPSession - summary with RandIP() does not crash
96+
97+
pkt = IP(dst=RandIP())
98+
s = pkt.summary()
99+
assert isinstance(s, str)
100+
95101
= StringBuffer
96102

97103
buffer = StringBuffer()

0 commit comments

Comments
 (0)