1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

nss: Protect against errno changes in function lookup (bug 28953)

dlopen may clobber errno.  The nss_test_errno module uses an ELF
constructor to achieve that, but there could be internal errors
during dlopen that cause this, too.  Therefore, the NSS framework
has to guard against such errno clobbers.

__nss_module_get_function is currently the only function that calls
__nss_module_load, so it is sufficient to save and restore errno
around this call.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 9bdf92c79d)
This commit is contained in:
Florian Weimer
2022-03-11 08:23:56 +01:00
parent c54c5cd8e3
commit 123bd1ec66
5 changed files with 143 additions and 4 deletions

View File

@@ -330,8 +330,18 @@ 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;
{
/* Reporting module load failure is currently inaccurate. See
bug 22041. Not changing errno is the conservative choice. */
__set_errno (saved_errno);
return NULL;
}
__set_errno (saved_errno);
function_name *name_entry = bsearch (name, nss_function_name_array,
array_length (nss_function_name_array),