about summary refs log tree commit diff
path: root/nis
diff options
context:
space:
mode:
Diffstat (limited to 'nis')
-rw-r--r--nis/nis_addmember.c16
-rw-r--r--nis/nis_checkpoint.c8
-rw-r--r--nis/nis_getservlist.c12
3 files changed, 29 insertions, 7 deletions
diff --git a/nis/nis_addmember.c b/nis/nis_addmember.c
index 2a31903572..3f1c2b3d99 100644
--- a/nis/nis_addmember.c
+++ b/nis/nis_addmember.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -50,13 +50,25 @@ nis_addmember (const_nis_name member, const_nis_name group)
 	}
       if ((NIS_RES_NUMOBJ (res)  != 1) ||
           (__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ))
-        return NIS_INVALIDOBJ;
+	{
+	  nis_freeresult (res);
+	  return NIS_INVALIDOBJ;
+	}
 
       NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val
 	= realloc (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val,
 		   (NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len + 1)
 		   * sizeof (char *));
+      if (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val == NULL)
+	goto nomem_out;
       NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len] = strdup (member);
+      if (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len] == NULL)
+	{
+	  free (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val);
+	nomem_out:
+	  nis_freeresult (res);
+	  return NIS_NOMEMORY;
+	}
       ++NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len;
 
       cp = stpcpy (buf, NIS_RES_OBJECT(res)->zo_name);
diff --git a/nis/nis_checkpoint.c b/nis/nis_checkpoint.c
index 15bae8be22..3d5847295b 100644
--- a/nis/nis_checkpoint.c
+++ b/nis/nis_checkpoint.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -39,11 +39,15 @@ nis_checkpoint(const_nis_name dirname)
 
       res2 = nis_lookup (dirname, EXPAND_NAME);
       if (NIS_RES_STATUS (res2) != NIS_SUCCESS)
-        return res2;
+	{
+	  free (res);
+	  return res2;
+	}
 
       /* Check if obj is really a diryectory object */
       if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ)
 	{
+	  nis_freeresult (res2);
 	  nis_freeresult (res);
 	  NIS_RES_STATUS (res) = NIS_INVALIDOBJ;
 	  return res;
diff --git a/nis/nis_getservlist.c b/nis/nis_getservlist.c
index f88c156f89..a6f43f880d 100644
--- a/nis/nis_getservlist.c
+++ b/nis/nis_getservlist.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -37,7 +37,7 @@ nis_getservlist (const_nis_name dir)
       nis_server *server;
 
       serv =
-	calloc (1, sizeof (nis_server *) *
+	malloc (sizeof (nis_server *) *
 		(NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1));
       if (serv == NULL)
 	return NULL;
@@ -53,10 +53,13 @@ nis_getservlist (const_nis_name dir)
           serv[i]->ep.ep_len = server->ep.ep_len;
           if (serv[i]->ep.ep_len > 0)
             {
-              unsigned long j;
+              unsigned long int j;
 
               serv[i]->ep.ep_val =
 		malloc (server->ep.ep_len * sizeof (endpoint));
+	      if (serv[i]->ep.ep_val == NULL)
+		return NULL;
+
               for (j = 0; j < serv[i]->ep.ep_len; ++j)
                 {
                   if (server->ep.ep_val[j].uaddr)
@@ -92,6 +95,9 @@ nis_getservlist (const_nis_name dir)
           else
             serv[i]->pkey.n_bytes = NULL;
         }
+      serv[i] = NULL;
+
+      nis_freeresult (res);
     }
   else
     {