aboutsummaryrefslogtreecommitdiff
path: root/nis/nis_table.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-09-25 19:44:55 +0000
committerUlrich Drepper <drepper@redhat.com>2003-09-25 19:44:55 +0000
commit901956a52a8b376daa61730f6560cdaddda4b6e2 (patch)
tree9b1a19dcbd4563fd13a412a0fe37b8d3191b3c56 /nis/nis_table.c
parented91314ee80dfdda09b365c4bb87d338bd43861d (diff)
downloadglibc-901956a52a8b376daa61730f6560cdaddda4b6e2.zip
glibc-901956a52a8b376daa61730f6560cdaddda4b6e2.tar.gz
glibc-901956a52a8b376daa61730f6560cdaddda4b6e2.tar.bz2
Update.
* nis/nis_table.c (nis_list): Always strdup string used with ibreq->ibr_name. Add several NULL pointer checks. * nis/nss_nisplus/nisplus-alias.c: Add check for NULL return value of nis_list. * nis/nss_nisplus/nisplus-ethers.c: Likewise. * nis/nss_nisplus/nisplus-grp.c: Likewise. * nis/nss_nisplus/nisplus-hosts.c: Likewise. * nis/nss_nisplus/nisplus-netgrp.c: Likewise. * nis/nss_nisplus/nisplus-network.c: Likewise. * nis/nss_nisplus/nisplus-proto.c: Likewise. * nis/nss_nisplus/nisplus-publickey.c: Likewise. * nis/nss_nisplus/nisplus-pwd.c: Likewise. * nis/nss_nisplus/nisplus-rpc.c: Likewise. * nis/nss_nisplus/nisplus-service.c: Likewise. * nis/nss_nisplus/nisplus-spwd.c: Likewise.
Diffstat (limited to 'nis/nis_table.c')
-rw-r--r--nis/nis_table.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/nis/nis_table.c b/nis/nis_table.c
index 3b02833..6c4fb83 100644
--- a/nis/nis_table.c
+++ b/nis/nis_table.c
@@ -176,8 +176,8 @@ nis_list (const_nis_name name, unsigned int flags,
return res;
}
- if ((flags & EXPAND_NAME) &&
- ibreq->ibr_name[strlen (ibreq->ibr_name) - 1] != '.')
+ if ((flags & EXPAND_NAME)
+ && ibreq->ibr_name[strlen (ibreq->ibr_name) - 1] != '.')
{
names = nis_getnames (ibreq->ibr_name);
free (ibreq->ibr_name);
@@ -189,6 +189,12 @@ nis_list (const_nis_name name, unsigned int flags,
return res;
}
ibreq->ibr_name = strdup (names[name_nr]);
+ if (ibreq->ibr_name == NULL)
+ {
+ nis_free_request (ibreq);
+ NIS_RES_STATUS (res) = NIS_NOMEMORY;
+ return res;
+ }
}
else
{
@@ -269,6 +275,12 @@ nis_list (const_nis_name name, unsigned int flags,
++count_links;
ibreq->ibr_name =
strdup (NIS_RES_OBJECT (res)->LI_data.li_name);
+ if (ibreq->ibr_name == NULL)
+ {
+ nis_free_request (ibreq);
+ NIS_RES_STATUS (res) = NIS_NOMEMORY;
+ return res;
+ }
if (NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len)
if (ibreq->ibr_srch.ibr_srch_len == 0)
{
@@ -309,6 +321,12 @@ nis_list (const_nis_name name, unsigned int flags,
if (ibreq->ibr_name == NULL || ibreq->ibr_name[0] == '\0')
{
ibreq->ibr_name = strdup ("");
+ if (ibreq->ibr_name == NULL)
+ {
+ nis_free_request (ibreq);
+ NIS_RES_STATUS (res) = NIS_NOMEMORY;
+ return res;
+ }
++done;
}
else
@@ -318,8 +336,7 @@ nis_list (const_nis_name name, unsigned int flags,
res = calloc (1, sizeof (nis_result));
if (res == NULL || ibreq->ibr_name == NULL)
{
- if (res)
- free (res);
+ free (res);
nis_free_request (ibreq);
if (have_tablepath)
free (tablepath);
@@ -364,6 +381,12 @@ nis_list (const_nis_name name, unsigned int flags,
}
else
ibreq->ibr_name = strdup (ibreq->ibr_name);
+ if (ibreq->ibr_name == NULL)
+ {
+ nis_free_request (ibreq);
+ NIS_RES_STATUS (res) = NIS_NOMEMORY;
+ return res;
+ }
}
}
break;
@@ -394,9 +417,10 @@ nis_list (const_nis_name name, unsigned int flags,
if (!first_try)
{
/* Try the next domainname if we don't follow a link. */
+ free (ibreq->ibr_name);
+ ibreq->ibr_name = NULL;
if (count_links)
{
- free (ibreq->ibr_name);
NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
++done;
break;
@@ -407,7 +431,13 @@ nis_list (const_nis_name name, unsigned int flags,
++done;
break;
}
- ibreq->ibr_name = names[name_nr];
+ ibreq->ibr_name = strdup (names[name_nr]);
+ if (ibreq->ibr_name == NULL)
+ {
+ nis_free_request (ibreq);
+ NIS_RES_STATUS (res) = NIS_NOMEMORY;
+ return res;
+ }
first_try = 1; /* Try old binding at first */
goto again;
}