From 831e98384b057a7e74aa615200752c1d84c017ee Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 11 Mar 2026 15:13:57 +1100 Subject: netlink: Allow NULL to be passed as addr parameter to nl_addr_get (again) A recent fix to nl_addr_get() unfortunately introduced a different problem. 251e676bd0bf removed a test if @addr was non-NULL. conf_ip6() relied on being able to pass NULL in order to update the link-local address without updating the main address (because it was already set by the user). This means that 'pasta -a 2001:db8::1' will SEGV. Reverse the incorrect part of the change to fix this. Fixes: 251e676bd0bf ("netlink: Return prefix length for IPv6 addresses in nl_addr_get()") Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlink.c b/netlink.c index ee9a6b1..e07b47f 100644 --- a/netlink.c +++ b/netlink.c @@ -788,7 +788,7 @@ int nl_addr_get(int s, unsigned int ifi, sa_family_t af, (af == AF_INET6 && rta->rta_type != IFA_ADDRESS)) continue; - if (ifa->ifa_prefixlen > prefix_max && + if (ifa->ifa_prefixlen > prefix_max && addr && (af == AF_INET || ifa->ifa_scope < RT_SCOPE_LINK)) { memcpy(addr, RTA_DATA(rta), RTA_PAYLOAD(rta)); -- cgit v1.2.3