* lib/shadowmem.c: Only copy the required fields of the struct

spwd. (start with the primitive types)
	* lib/shadowmem.c: Avoid memzero() on a possibly NULL pointer.
	* lib/groupmem.c: Only copy the required fields of the struct
	group. (start with the primitive types)
	* lib/groupmem.c: Avoid memzero() on a possibly NULL pointer.
	* lib/groupmem.c: Free gr_mem in addition to its elements.
	* lib/sgroupio.c: The struct sgrp has no primitive types to be
	copied initially.
	* lib/sgroupio.c: Avoid memzero() on a possibly NULL pointer.
	* lib/sgroupio.c: Free sg_mem and sg_add in addition to their
	elements.
	* lib/pwmem.c: Only copy the required fields of the struct
	passwd. (start with the primitive types)
This commit is contained in:
nekral-guest
2009-09-07 19:08:10 +00:00
parent 1a86dc913f
commit d346c7c6a7
5 changed files with 57 additions and 22 deletions

View File

@@ -48,7 +48,7 @@
if (NULL == gr) {
return NULL;
}
*gr = *grent;
gr->gr_gid = grent->gr_gid;
gr->gr_name = strdup (grent->gr_name);
if (NULL == gr->gr_name) {
free(gr);
@@ -90,12 +90,17 @@
void gr_free (/*@out@*/ /*@only@*/struct group *grent)
{
size_t i;
free (grent->gr_name);
memzero (grent->gr_passwd, strlen (grent->gr_passwd));
free (grent->gr_passwd);
while (*(grent->gr_mem)) {
free (*(grent->gr_mem));
grent->gr_mem++;
if (NULL != grent->gr_passwd) {
memzero (grent->gr_passwd, strlen (grent->gr_passwd));
free (grent->gr_passwd);
}
if (NULL != grent->gr_mem) {
for (i = 0; NULL != grent->gr_mem[i]; i++) {
free (grent->gr_mem[i]);
}
free (grent->gr_mem);
}
free (grent);
}