[PATCH 1/3] inet: Fix getnameinfo (NI_NOFQDN) race condition (BZ#28566)
Florian Weimer
fweimer@redhat.com
Thu Nov 11 08:16:31 GMT 2021
* Adhemerval Zanella via Libc-alpha:
> diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
> index 8380d85783..58ebbb1154 100644
> --- a/inet/getnameinfo.c
> +++ b/inet/getnameinfo.c
> @@ -86,55 +86,75 @@ libc_freeres_ptr (static char *domain);
> static char *
> nrl_domainname (void)
> {
> + __libc_lock_define_initialized (static, lock);
> + __libc_lock_lock (lock);
>
> + static bool not_first = false;
> if (! not_first)
> + done:
> + scratch_buffer_free (&tmpbuf);
> + not_first = true;
This is missing the acquire/release pairing for the double-checked
locking idiom. You can probably use the domain variable directly.
> - if ((c = strchr (tmpbuf.data, '.')))
> + if (h && (c = strchr(h->h_name, '.')))
h != NULL?
> + if (!scratch_buffer_grow_preserve (&tmpbuf))
I think the change to _preserve should be in the alloca elimination
patch (but see my comment there).
Thanks,
Florian
More information about the Libc-alpha
mailing list