miniupnpd: find_ipv6_addr() avoid fc00::/7 if possible

fc00::/7 = RFC4193 Unique Local IPv6 Unicast Addresses
This commit is contained in:
Thomas Bernard 2024-04-29 01:16:06 +02:00
parent 69638d0100
commit 65ad337f70
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
1 changed files with 5 additions and 2 deletions

View File

@ -2,7 +2,7 @@
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2023 Thomas Bernard
* (c) 2006-2024 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
@ -264,7 +264,10 @@ find_ipv6_addr(const char * ifname,
{
addr = (const struct sockaddr_in6 *)ife->ifa_addr;
if(!IN6_IS_ADDR_LOOPBACK(&addr->sin6_addr)
&& !IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr))
&& !IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr)
/* RFC4193 "Unique Local IPv6 Unicast Addresses" only if no
* other address found */
&& (r == 0 || (addr->sin6_addr.s6_addr[0] & 0xfe) != 0xfc))
{
inet_ntop(ife->ifa_addr->sa_family,
&addr->sin6_addr,