This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! Two problems: 1) there is a memory leak - if result != 0 (-1 means allocation failure, 1 that we found the netgroup entry we are looking for), innetgr did not call endnetgrent hook, so resources in the NSS module weren't freed. 2) innetgr return value is supposed to be 1 for match and 0 for non-match or error (from info libc): The return value is `1' if an entry matching the given triple is found in the netgroup. The return value is `0' if the netgroup itself is not found, the netgroup does not contain the triple or internal errors occurred. result variable internally is 0 for non-match, 1 for match and -1 for internal error (the distinction is needed to find out if the loop should continue), so return result == 1; which is what getnetgrent_r.c used until August last year is IMHO correct. 2005-09-24 Jakub Jelinek <jakub@redhat.com. * inet/getnetgrent_r.c (innetgr): Call endfct even if result != 0. Return 1 only if result == 1. Patch by Benoit Capelle. --- libc/inet/getnetgrent_r.c.jj 2005-09-12 09:20:29.000000000 +0200 +++ libc/inet/getnetgrent_r.c 2005-09-24 20:53:51.000000000 +0200 @@ -409,9 +409,6 @@ innetgr (const char *netgroup, const cha } } - if (result != 0) - break; - /* If we found one service which does know the given netgroup we don't try further. */ status = NSS_STATUS_RETURN; @@ -422,6 +419,9 @@ innetgr (const char *netgroup, const cha if (endfct != NULL) (*endfct) (&entry); + if (result != 0) + break; + /* Look for the next service. */ no_more = __nss_next (&entry.nip, "setnetgrent", &setfct.ptr, status, 0); @@ -444,6 +444,6 @@ innetgr (const char *netgroup, const cha /* Free the memory. */ free_memory (&entry); - return result; + return result == 1; } libc_hidden_def (innetgr) Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |