[PATCH 3/3] nss: Handle nss_load_library out of memory case
Jiri Olsa
jolsa@redhat.com
Thu Sep 15 14:24:00 GMT 2011
If nss_load_library function fails with out of memory error,
the current code frees the key and then removes it from the tree,
which ends up with the crash.
We need to remove the key from the tree first and then free it.
I'm not sure we want to keep the key in tree in case:
'ni->library->lib_handle == (void *) -1'
but since it seems to be current behaviour I kept it.
---
2011-09-15 Jiri Olsa <jolsa@redhat.com>
* nss/nsswitch.c (__nss_lookup_function): Handle
nss_load_library out of memory case.
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 2646d9a..a60a67f 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -402,7 +402,6 @@ __nss_lookup_function (service_user *ni, const char *fct_name)
known_function *known = malloc (sizeof *known);
if (! known)
{
- remove_from_tree:
/* Oops. We can't instantiate this node properly.
Remove it from the tree. */
__tdelete (&fct_name, &ni->known, &known_compare);
@@ -419,11 +418,11 @@ __nss_lookup_function (service_user *ni, const char *fct_name)
if (nss_load_library (ni) != 0)
{
/* This only happens when out of memory. */
+ __tdelete (&fct_name, &ni->known, &known_compare);
free (known);
- goto remove_from_tree;
+ result = NULL;
}
-
- if (ni->library->lib_handle == (void *) -1l)
+ else if (ni->library->lib_handle == (void *) -1l)
/* Library not found => function not found. */
result = NULL;
else
--
1.7.4.4
More information about the Libc-alpha
mailing list