about summary refs log tree commit diff
path: root/nis/nis_removemember.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-05-07 03:57:57 +0000
committerUlrich Drepper <drepper@redhat.com>2004-05-07 03:57:57 +0000
commit9be31a514921c7415d61834ffa1387f24f631dfb (patch)
treee6d77813cd31858a49c7315b98510e3e3fc06c13 /nis/nis_removemember.c
parentf1debaf68214cb898f67355ee83169cc135e14e9 (diff)
downloadglibc-9be31a514921c7415d61834ffa1387f24f631dfb.tar.gz
glibc-9be31a514921c7415d61834ffa1387f24f631dfb.tar.xz
glibc-9be31a514921c7415d61834ffa1387f24f631dfb.zip
Update.
	* sysdeps/unix/sysv/linux/ifreq.c (__ifreq): Fix memory handling.
	* sysdeps/generic/ifreq.c (__ifreq): Fix memory handling.

	* resolv/res_hconf.c (_res_hconf_reorder_addrs): Make clear that
	realloc cannot fail.

	* nss/nss_files/files-netgrp.c (EXPAND): Free buffer which cannot
	be expanded.

	* nis/nis_table.c: Clean up memory handling.
	* nis/nis_subr.c (nis_getnames): Clean up memory handling.
	* nis/nis_removemember.c (nis_removemember): Add comment
	explaining use of realloc.
Diffstat (limited to 'nis/nis_removemember.c')
-rw-r--r--nis/nis_removemember.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/nis/nis_removemember.c b/nis/nis_removemember.c
index 930ca4311f..b9e27ab48c 100644
--- a/nis/nis_removemember.c
+++ b/nis/nis_removemember.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <string.h>
 #include <rpcsvc/nis.h>
 
@@ -87,6 +88,10 @@ nis_removemember (const_nis_name member, const_nis_name group)
 	    }
 	}
       free (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val);
+      assert (k <= NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len);
+      /* This realloc() call always decreases the size.  This cannot
+	 fail.  We still have the test but do not recover memory
+	 (i.e., we overwrite the input pointer).  */
       newmem = realloc (newmem, k * sizeof (char*));
       if (newmem == NULL)
 	return NIS_NOMEMORY;