From 93c94722da7ac3c8a5e02d164bfd9237172e0f6e Mon Sep 17 00:00:00 2001 From: gpotter2 <10530980+gpotter2@users.noreply.github.com> Date: Sun, 6 Oct 2024 23:36:15 +0200 Subject: [PATCH] Work around GH#4541 (#4560) --- scapy/arch/linux/rtnetlink.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scapy/arch/linux/rtnetlink.py b/scapy/arch/linux/rtnetlink.py index a5e18bdb6..e57d2459c 100644 --- a/scapy/arch/linux/rtnetlink.py +++ b/scapy/arch/linux/rtnetlink.py @@ -887,6 +887,9 @@ def read_routes(): ifaces = _get_if_list() results = _read_routes(socket.AF_INET) for msg in results: + # Omit stupid answers (some OS conf appears to lead to this) + if msg.rtm_family != socket.AF_INET: + continue # Process the RTM_NEWROUTE net = 0 mask = itom(msg.rtm_dst_len) @@ -937,6 +940,9 @@ def read_routes6(): results = _read_routes(socket.AF_INET6) lifaddr = _get_ips(af_family=socket.AF_INET6) for msg in results: + # Omit stupid answers (some OS conf appears to lead to this) + if msg.rtm_family != socket.AF_INET6: + continue # Process the RTM_NEWROUTE prefix = "::" plen = msg.rtm_dst_len