[PATCH v2 2/2] nss: Protect against errno changes in function lookup (bug 28953)

Andreas Schwab schwab@linux-m68k.org
Thu Mar 10 15:14:04 GMT 2022


On Mär 10 2022, Florian Weimer via Libc-alpha wrote:

> diff --git a/nss/nss_module.c b/nss/nss_module.c
> index f9a1263e5a..4839448e35 100644
> --- a/nss/nss_module.c
> +++ b/nss/nss_module.c
> @@ -330,9 +330,14 @@ name_search (const void *left, const void *right)
>  void *
>  __nss_module_get_function (struct nss_module *module, const char *name)
>  {
> +  /* A successful dlopen might clobber errno.   */
> +  int saved_errno = errno;
> +
>    if (!__nss_module_load (module))
>      return NULL;
>  
> +  __set_errno (saved_errno);
> +

Is an unsuccessful load allowed to change errno?

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


More information about the Libc-alpha mailing list