aboutsummaryrefslogtreecommitdiff
path: root/nis
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
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')
-rw-r--r--nis/nis_table.c42
-rw-r--r--nis/nss_nisplus/nisplus-alias.c23
-rw-r--r--nis/nss_nisplus/nisplus-ethers.c12
-rw-r--r--nis/nss_nisplus/nisplus-grp.c28
-rw-r--r--nis/nss_nisplus/nisplus-hosts.c42
-rw-r--r--nis/nss_nisplus/nisplus-netgrp.c9
-rw-r--r--nis/nss_nisplus/nisplus-network.c43
-rw-r--r--nis/nss_nisplus/nisplus-proto.c42
-rw-r--r--nis/nss_nisplus/nisplus-publickey.c22
-rw-r--r--nis/nss_nisplus/nisplus-pwd.c12
-rw-r--r--nis/nss_nisplus/nisplus-rpc.c42
-rw-r--r--nis/nss_nisplus/nisplus-service.c44
-rw-r--r--nis/nss_nisplus/nisplus-spwd.c7
13 files changed, 275 insertions, 93 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;
}
diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c
index e05c5ed..152e5fc 100644
--- a/nis/nss_nisplus/nisplus-alias.c
+++ b/nis/nss_nisplus/nisplus-alias.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -167,11 +167,19 @@ internal_setaliasent (void)
next_entry = 0;
result = nis_list (tablename_val, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
- status = niserr2nss (result->status);
- if (status != NSS_STATUS_SUCCESS)
+ if (result == NULL)
{
- nis_freeresult (result);
- result = NULL;
+ status = NSS_STATUS_TRYAGAIN;
+ __set_errno (ENOMEM);
+ }
+ else
+ {
+ status = niserr2nss (result->status);
+ if (status != NSS_STATUS_SUCCESS)
+ {
+ nis_freeresult (result);
+ result = NULL;
+ }
}
return status;
}
@@ -280,6 +288,11 @@ _nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias,
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
return niserr2nss (result->status);
diff --git a/nis/nss_nisplus/nisplus-ethers.c b/nis/nss_nisplus/nisplus-ethers.c
index 2fd152d..028309c 100644
--- a/nis/nss_nisplus/nisplus-ethers.c
+++ b/nis/nss_nisplus/nisplus-ethers.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,2000,2001,2002,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
@@ -237,6 +237,11 @@ _nss_nisplus_gethostton_r (const char *name, struct etherent *eth,
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
@@ -294,6 +299,11 @@ _nss_nisplus_getntohost_r (const struct ether_addr *addr,
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
diff --git a/nis/nss_nisplus/nisplus-grp.c b/nis/nss_nisplus/nisplus-grp.c
index f66c14f..daca94f 100644
--- a/nis/nss_nisplus/nisplus-grp.c
+++ b/nis/nss_nisplus/nisplus-grp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -72,11 +72,19 @@ internal_setgrent (void)
return NSS_STATUS_UNAVAIL;
result = nis_list (tablename_val, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
- status = niserr2nss (result->status);
- if (status != NSS_STATUS_SUCCESS)
+ if (result == NULL)
{
- nis_freeresult (result);
- result = NULL;
+ status = NSS_STATUS_TRYAGAIN;
+ __set_errno (ENOMEM);
+ }
+ else
+ {
+ status = niserr2nss (result->status);
+ if (status != NSS_STATUS_SUCCESS)
+ {
+ nis_freeresult (result);
+ result = NULL;
+ }
}
return status;
}
@@ -186,6 +194,11 @@ _nss_nisplus_getgrnam_r (const char *name, struct group *gr,
result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
@@ -236,6 +249,11 @@ _nss_nisplus_getgrgid_r (const gid_t gid, struct group *gr,
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c
index b8c9fdf..5404698 100644
--- a/nis/nss_nisplus/nisplus-hosts.c
+++ b/nis/nss_nisplus/nisplus-hosts.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997,1998,1999,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
@@ -361,21 +361,30 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
sprintf (buf, "[name=%s],%s", name, tablename_val);
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
- /* If we do not find it, try it as original name. But if the
- database is correct, we should find it in the first case, too */
- if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS)
- || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
- || strcmp (result->objects.objects_val->EN_data.en_type,
- "hosts_tbl") != 0
- || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3)
- sprintf (buf, "[cname=%s],%s", name, tablename_val);
- else
- sprintf (buf, "[cname=%s],%s", NISENTRYVAL(0, 0, result),
- tablename_val);
+ if (result != NULL)
+ {
+ /* If we do not find it, try it as original name. But if the
+ database is correct, we should find it in the first case, too */
+ if ((result->status != NIS_SUCCESS
+ && result->status != NIS_S_SUCCESS)
+ || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
+ || strcmp (result->objects.objects_val->EN_data.en_type,
+ "hosts_tbl") != 0
+ || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3)
+ sprintf (buf, "[cname=%s],%s", name, tablename_val);
+ else
+ sprintf (buf, "[cname=%s],%s", NISENTRYVAL(0, 0, result),
+ tablename_val);
- nis_freeresult (result);
- result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ nis_freeresult (result);
+ result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ }
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
retval = niserr2nss (result->status);
if (retval != NSS_STATUS_SUCCESS)
{
@@ -479,6 +488,11 @@ _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
inet_ntoa (*(const struct in_addr *) addr), tablename_val);
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ __set_errno (ENOMEM);
+ return NSS_STATUS_TRYAGAIN;
+ }
retval = niserr2nss (result->status);
if (retval != NSS_STATUS_SUCCESS)
{
diff --git a/nis/nss_nisplus/nisplus-netgrp.c b/nis/nss_nisplus/nisplus-netgrp.c
index 831a13d..2d5ddf0 100644
--- a/nis/nss_nisplus/nisplus-netgrp.c
+++ b/nis/nss_nisplus/nisplus-netgrp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -153,7 +153,12 @@ _nss_nisplus_setnetgrent (const char *group, struct __netgrent *dummy)
data = nis_list (buf, EXPAND_NAME, NULL, NULL);
- if (niserr2nss (data->status) != NSS_STATUS_SUCCESS)
+ if (data == NULL)
+ {
+ __set_errno (ENOMEM);
+ status = NSS_STATUS_TRYAGAIN;
+ }
+ else if (niserr2nss (data->status) != NSS_STATUS_SUCCESS)
{
status = niserr2nss (data->status);
nis_freeresult (data);
diff --git a/nis/nss_nisplus/nisplus-network.c b/nis/nss_nisplus/nisplus-network.c
index d99bf76..422b02b 100644
--- a/nis/nss_nisplus/nisplus-network.c
+++ b/nis/nss_nisplus/nisplus-network.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,2000,2001,2002,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -319,21 +319,31 @@ _nss_nisplus_getnetbyname_r (const char *name, struct netent *network,
sprintf (buf, "[name=%s],%s", name, tablename_val);
result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
- /* If we do not find it, try it as original name. But if the
- database is correct, we should find it in the first case, too */
- if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS)
- || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
- || strcmp (result->objects.objects_val[0].EN_data.en_type,
- "networks_tbl") != 0
- || result->objects.objects_val[0].EN_data.en_cols.en_cols_len < 3)
- sprintf (buf, "[cname=%s],%s", name, tablename_val);
- else
- sprintf (buf, "[cname=%s],%s", NISENTRYVAL (0, 0, result),
- tablename_val);
+ if (result != NULL)
+ {
+ /* If we do not find it, try it as original name. But if the
+ database is correct, we should find it in the first case, too */
+ if ((result->status != NIS_SUCCESS
+ && result->status != NIS_S_SUCCESS)
+ || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
+ || strcmp (result->objects.objects_val[0].EN_data.en_type,
+ "networks_tbl") != 0
+ || (result->objects.objects_val[0].EN_data.en_cols.en_cols_len
+ < 3))
+ sprintf (buf, "[cname=%s],%s", name, tablename_val);
+ else
+ sprintf (buf, "[cname=%s],%s", NISENTRYVAL (0, 0, result),
+ tablename_val);
- nis_freeresult (result);
- result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
+ nis_freeresult (result);
+ result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
+ }
+ if (result == NULL)
+ {
+ __set_errno (ENOMEM);
+ return NSS_STATUS_TRYAGAIN;
+ }
retval = niserr2nss (result->status);
if (retval != NSS_STATUS_SUCCESS)
{
@@ -402,6 +412,11 @@ _nss_nisplus_getnetbyaddr_r (uint32_t addr, const int type,
sprintf (buf, "[addr=%s],%s", buf2, tablename_val);
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
+ if (result == NULL)
+ {
+ __set_errno (ENOMEM);
+ return NSS_STATUS_TRYAGAIN;
+ }
retval = niserr2nss (result->status);
if (retval != NSS_STATUS_SUCCESS)
{
diff --git a/nis/nss_nisplus/nisplus-proto.c b/nis/nss_nisplus/nisplus-proto.c
index 10f9a38..83456ca 100644
--- a/nis/nss_nisplus/nisplus-proto.c
+++ b/nis/nss_nisplus/nisplus-proto.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -296,21 +296,30 @@ _nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto,
sprintf (buf, "[name=%s],%s", name, tablename_val);
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
- /* If we do not find it, try it as original name. But if the
- database is correct, we should find it in the first case, too */
- if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS)
- || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
- || strcmp (result->objects.objects_val->EN_data.en_type,
- "protocols_tbl") != 0
- || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3)
- sprintf (buf, "[cname=%s],%s", name, tablename_val);
- else
- sprintf (buf, "[cname=%s],%s", NISENTRYVAL (0, 0, result),
- tablename_val);
+ if (result != NULL)
+ {
+ /* If we do not find it, try it as original name. But if the
+ database is correct, we should find it in the first case, too */
+ if ((result->status != NIS_SUCCESS
+ && result->status != NIS_S_SUCCESS)
+ || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
+ || strcmp (result->objects.objects_val->EN_data.en_type,
+ "protocols_tbl") != 0
+ || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3)
+ sprintf (buf, "[cname=%s],%s", name, tablename_val);
+ else
+ sprintf (buf, "[cname=%s],%s", NISENTRYVAL (0, 0, result),
+ tablename_val);
- nis_freeresult (result);
- result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ nis_freeresult (result);
+ result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ }
+ if (result == NULL)
+ {
+ __set_errno (ENOMEM);
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
@@ -365,6 +374,11 @@ _nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto,
result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
+ if (result == NULL)
+ {
+ __set_errno (ENOMEM);
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
diff --git a/nis/nss_nisplus/nisplus-publickey.c b/nis/nss_nisplus/nisplus-publickey.c
index ec1290a..58ae701 100644
--- a/nis/nss_nisplus/nisplus-publickey.c
+++ b/nis/nss_nisplus/nisplus-publickey.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1999, 2001 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
@@ -74,6 +74,11 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey, int *errnop)
res = nis_list (buf, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
NULL, NULL);
+ if (res == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
retval = niserr2nss (res->status);
if (retval != NSS_STATUS_SUCCESS)
@@ -152,6 +157,11 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd,
res = nis_list (buf, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
NULL, NULL);
+ if (res == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
retval = niserr2nss (res->status);
if (retval != NSS_STATUS_SUCCESS)
@@ -269,6 +279,11 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
/* XXX but we cant, for now. XXX */
res = nis_list (sname, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
NULL, NULL);
+ if (res == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
switch (res->status)
{
case NIS_SUCCESS:
@@ -337,6 +352,11 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
/* XXX but we cant, for now. XXX */
res = nis_list (sname, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
NULL, NULL);
+ if (res == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
switch(res->status)
{
case NIS_NOTFOUND:
diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c
index a4beb7a..8f3bc99 100644
--- a/nis/nss_nisplus/nisplus-pwd.c
+++ b/nis/nss_nisplus/nisplus-pwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -192,6 +192,11 @@ _nss_nisplus_getpwnam_r (const char *name, struct passwd *pw,
result = nis_list(buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
@@ -246,6 +251,11 @@ _nss_nisplus_getpwuid_r (const uid_t uid, struct passwd *pw,
result = nis_list(buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
diff --git a/nis/nss_nisplus/nisplus-rpc.c b/nis/nss_nisplus/nisplus-rpc.c
index 8e661ba..31d48d1 100644
--- a/nis/nss_nisplus/nisplus-rpc.c
+++ b/nis/nss_nisplus/nisplus-rpc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -290,21 +290,30 @@ _nss_nisplus_getrpcbyname_r (const char *name, struct rpcent *rpc,
sprintf (buf, "[name=%s],%s", name, tablename_val);
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
- /* If we do not find it, try it as original name. But if the
- database is correct, we should find it in the first case, too */
- if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS)
- || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
- || strcmp (result->objects.objects_val->EN_data.en_type,
- "rpc_tbl") != 0
- || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3)
- sprintf (buf, "[cname=%s],%s", name, tablename_val);
- else
- sprintf (buf, "[cname=%s],%s", NISENTRYVAL (0, 0, result),
- tablename_val);
+ if (result != NULL)
+ {
+ /* If we do not find it, try it as original name. But if the
+ database is correct, we should find it in the first case, too */
+ if ((result->status != NIS_SUCCESS
+ && result->status != NIS_S_SUCCESS)
+ || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
+ || strcmp (result->objects.objects_val->EN_data.en_type,
+ "rpc_tbl") != 0
+ || result->objects.objects_val->EN_data.en_cols.en_cols_len < 3)
+ sprintf (buf, "[cname=%s],%s", name, tablename_val);
+ else
+ sprintf (buf, "[cname=%s],%s", NISENTRYVAL (0, 0, result),
+ tablename_val);
- nis_freeresult (result);
- result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS , NULL, NULL);
+ nis_freeresult (result);
+ result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS , NULL, NULL);
+ }
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
@@ -357,6 +366,11 @@ _nss_nisplus_getrpcbynumber_r (const int number, struct rpcent *rpc,
result = nis_list(buf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
diff --git a/nis/nss_nisplus/nisplus-service.c b/nis/nss_nisplus/nisplus-service.c
index a010f44..fbb6987 100644
--- a/nis/nss_nisplus/nisplus-service.c
+++ b/nis/nss_nisplus/nisplus-service.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,1999,2001,2002,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
@@ -305,22 +305,31 @@ _nss_nisplus_getservbyname_r (const char *name, const char *protocol,
tablename_val);
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
- /* If we do not find it, try it as original name. But if the
- database is correct, we should find it in the first case, too */
- if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS)
- || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
- || strcmp (result->objects.objects_val->EN_data.en_type,
- "services_tbl") != 0
- || result->objects.objects_val->EN_data.en_cols.en_cols_len < 4)
- sprintf (buf, "[cname=%s,proto=%s],%s", name, protocol,
- tablename_val);
- else
- sprintf (buf, "[cname=%s,proto=%s],%s",
- NISENTRYVAL (0, 0, result), protocol, tablename_val);
+ if (result != NULL)
+ {
+ /* If we do not find it, try it as original name. But if the
+ database is correct, we should find it in the first case, too */
+ if ((result->status != NIS_SUCCESS
+ && result->status != NIS_S_SUCCESS)
+ || __type_of (result->objects.objects_val) != NIS_ENTRY_OBJ
+ || strcmp (result->objects.objects_val->EN_data.en_type,
+ "services_tbl") != 0
+ || result->objects.objects_val->EN_data.en_cols.en_cols_len < 4)
+ sprintf (buf, "[cname=%s,proto=%s],%s", name, protocol,
+ tablename_val);
+ else
+ sprintf (buf, "[cname=%s,proto=%s],%s",
+ NISENTRYVAL (0, 0, result), protocol, tablename_val);
- nis_freeresult (result);
- result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ nis_freeresult (result);
+ result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ }
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
@@ -382,6 +391,11 @@ _nss_nisplus_getservbyport_r (const int number, const char *protocol,
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);
diff --git a/nis/nss_nisplus/nisplus-spwd.c b/nis/nss_nisplus/nisplus-spwd.c
index 5cff1b7..c317469 100644
--- a/nis/nss_nisplus/nisplus-spwd.c
+++ b/nis/nss_nisplus/nisplus-spwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -192,6 +192,11 @@ _nss_nisplus_getspnam_r (const char *name, struct spwd *sp,
result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
+ if (result == NULL)
+ {
+ *errnop = ENOMEM;
+ return NSS_STATUS_TRYAGAIN;
+ }
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
{
enum nss_status status = niserr2nss (result->status);