From 140ba648280136ce71b6734dae43ac4f00fae4e9 Mon Sep 17 00:00:00 2001 From: Kelvin Estrada Date: Mon, 5 Jan 2026 21:39:01 -0400 Subject: [PATCH] Fix IP.Summary() crash when dst is RandIP() --- scapy/layers/inet.py | 2 ++ test/scapy/layers/inet.uts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/scapy/layers/inet.py b/scapy/layers/inet.py index cc3ea479a62..da98ab018c7 100644 --- a/scapy/layers/inet.py +++ b/scapy/layers/inet.py @@ -586,6 +586,8 @@ def route(self): if conf.route is None: # unused import, only to initialize conf.route import scapy.route # noqa: F401 + if not isinstance(dst, (str, bytes, int)): + dst = str(dst) return conf.route.route(dst, dev=scope) def hashret(self): diff --git a/test/scapy/layers/inet.uts b/test/scapy/layers/inet.uts index ab5cbd56781..d898c0ef6d7 100644 --- a/test/scapy/layers/inet.uts +++ b/test/scapy/layers/inet.uts @@ -92,6 +92,12 @@ pkts = sniff(offline=pkts, session=IPSession) assert len(pkts) == 2 assert pkts[1].load == b"X" * 1500 += IPSession - summary with RandIP() does not crash + +pkt = IP(dst=RandIP()) +s = pkt.summary() +assert isinstance(s, str) + = StringBuffer buffer = StringBuffer()