[PATCH v2 2/2] nss: Protect against errno changes in function lookup (bug 28953)
Florian Weimer
fweimer@redhat.com
Thu Mar 10 15:39:36 GMT 2022
* Andreas Schwab:
> 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?
This is bug 22041 territory. I think in the current code, we should not
change errno here. Good catch. I'll send a v3.
Thanks,
Florian
More information about the Libc-alpha
mailing list