From c76feb81477381f6c1170c0fab5ee8fe54df1217 Mon Sep 17 00:00:00 2001 From: gpotter2 <10530980+gpotter2@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:53:03 +0200 Subject: [PATCH] Work around GH#4541 --- 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 a5e18bdb698..e57d2459c8c 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