aboutsummaryrefslogtreecommitdiff
path: root/nis/nss_nisplus/nisplus-hosts.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/nss_nisplus/nisplus-hosts.c
parented91314ee80dfdda09b365c4bb87d338bd43861d (diff)
downloadglibc-901956a52a8b376daa61730f6560cdaddda4b6e2.tar
glibc-901956a52a8b376daa61730f6560cdaddda4b6e2.tar.gz
glibc-901956a52a8b376daa61730f6560cdaddda4b6e2.tar.bz2
glibc-901956a52a8b376daa61730f6560cdaddda4b6e2.zip
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/nss_nisplus/nisplus-hosts.c')
-rw-r--r--nis/nss_nisplus/nisplus-hosts.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c
index b8c9fdf228..540469894e 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)
{