about summary refs log tree commit diff
path: root/nis/nss_nisplus/nisplus-rpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nss_nisplus/nisplus-rpc.c')
-rw-r--r--nis/nss_nisplus/nisplus-rpc.c42
1 files changed, 28 insertions, 14 deletions
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);