diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-09-25 19:44:55 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-09-25 19:44:55 +0000 |
commit | 901956a52a8b376daa61730f6560cdaddda4b6e2 (patch) | |
tree | 9b1a19dcbd4563fd13a412a0fe37b8d3191b3c56 /nis/nss_nisplus | |
parent | ed91314ee80dfdda09b365c4bb87d338bd43861d (diff) | |
download | glibc-901956a52a8b376daa61730f6560cdaddda4b6e2.tar.gz |
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')
-rw-r--r-- | nis/nss_nisplus/nisplus-alias.c | 23 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-ethers.c | 12 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-grp.c | 28 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-hosts.c | 42 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-netgrp.c | 9 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-network.c | 43 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-proto.c | 42 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-publickey.c | 22 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-pwd.c | 12 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-rpc.c | 42 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-service.c | 44 | ||||
-rw-r--r-- | nis/nss_nisplus/nisplus-spwd.c | 7 |
12 files changed, 239 insertions, 87 deletions
diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c index e05c5edda3..152e5fc3fc 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 2fd152dfdb..028309c841 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 f66c14f8ed..daca94fc87 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 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) { diff --git a/nis/nss_nisplus/nisplus-netgrp.c b/nis/nss_nisplus/nisplus-netgrp.c index 831a13d891..2d5ddf084e 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 d99bf76ca4..422b02b82a 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 10f9a38e67..83456cae64 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 ec1290a683..58ae7012af 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 a4beb7af14..8f3bc997b3 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 8e661baedb..31d48d17a3 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 a010f44da8..fbb6987e9e 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 5cff1b7850..c317469137 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); |