|
|
Message-ID: <20261022123846.GD23438@brightrain.aerifal.cx>
Date: Thu, 22 Oct 2026 08:38:47 -0400
From: Rich Felker <dalias@...c.org>
To: Skye Soss <skye@...s.website>
Cc: musl <musl@...ts.openwall.com>
Subject: Re: [PATCH] getaddrinfo: link-local scope for IPv4 addresses
On Mon, Oct 19, 2026 at 02:41:37PM -0500, Skye Soss wrote:
> RFC 6724 section 3.2 assigns the IPv4 loopback prefix (127/8) and the
> IPv4 link-local prefix (169.254/16) as having link-local scope.
>
> This changes the order of some getaddrinfo queries as IPv4 addresses in
> those prefixes will now sort lower than IPv6 ULAs.
> ---
> src/network/lookup_name.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c
> index 35218185..6b7ed85e 100644
> --- a/src/network/lookup_name.c
> +++ b/src/network/lookup_name.c
> @@ -277,6 +277,10 @@ static int scopeof(const struct in6_addr *a)
> if (IN6_IS_ADDR_LINKLOCAL(a)) return 2;
> if (IN6_IS_ADDR_LOOPBACK(a)) return 2;
> if (IN6_IS_ADDR_SITELOCAL(a)) return 5;
> + if (IN6_IS_ADDR_V4MAPPED(a)) {
> + if (a->s6_addr[12] == 127) return 2;
> + if (a->s6_addr[12] == 169 && a->s6_addr[13] == 254) return 2;
> + }
> return 14;
> }
Thanks. As we discussed on IRC, making this behave consistently
requires also removing the logic that skips the RFC 6724 result
sorting when the results are v4-only. I think that's fine (and we can
still skip it when there's only one result, which is fairly common)
but I think I will wait to merge this until after the 1.2.7 release
since it's a more invasive change. Release should be very soon now
that the regex vuln is taken care of.
Also, reminder to self: fix the indentation when applying.
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.