]> granicus.if.org Git - shadow/commitdiff
* lib/shadowmem.c: Only copy the required fields of the struct
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 7 Sep 2009 19:08:10 +0000 (19:08 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 7 Sep 2009 19:08:10 +0000 (19:08 +0000)
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)

ChangeLog
lib/groupmem.c
lib/pwmem.c
lib/sgroupio.c
lib/shadowmem.c

index 57e7e56f30a00fd39a8e64643df456a4748b3620..befe7550463e09b0688f4cae5487fb7ac68fc308 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-09-07  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * 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)
+
 2009-09-07  Nicolas François  <nicolas.francois@centraliens.net>
 
        * lib/sgroupio.h: Harmonize splint annotations of sgr_locate()
index fed03bc6b1fe5c72a23418ad82a0e765908f2a15..3add3c807bfebd518094806393e4df9187dcee10 100644 (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);
 
 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);
 }
index a1b3411b78714c24eb9014765cf997bd0e95ebf8..5569191a858af62e2aec35326da55641e99b0b6f 100644 (file)
@@ -48,7 +48,8 @@
        if (NULL == pw) {
                return NULL;
        }
-       *pw = *pwent;
+       pw->pw_uid = pwent->pw_uid;
+       pw->pw_gid = pwent->pw_gid;
        pw->pw_name = strdup (pwent->pw_name);
        if (NULL == pw->pw_name) {
                free(pw);
 void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent)
 {
        free (pwent->pw_name);
-       memzero (pwent->pw_passwd, strlen (pwent->pw_passwd));
-       free (pwent->pw_passwd);
+       if (pwent->pw_passwd) {
+               memzero (pwent->pw_passwd, strlen (pwent->pw_passwd));
+               free (pwent->pw_passwd);
+       }
        free (pwent->pw_gecos);
        free (pwent->pw_dir);
        free (pwent->pw_shell);
index 5a882cc9ab952e76581e6cf115ec69062f0ae07b..836fc2768c557c5fa29b8fcc13c2aef8830ba1ef 100644 (file)
@@ -51,7 +51,6 @@
        if (NULL == sg) {
                return NULL;
        }
-       *sg = *sgent;
        sg->sg_name = strdup (sgent->sg_name);
        if (NULL == sg->sg_name) {
                free (sg);
@@ -137,17 +136,20 @@ static void gshadow_free (/*@out@*/ /*@only@*/void *ent)
 
 void sgr_free (/*@out@*/ /*@only@*/struct sgrp *sgent)
 {
+       size_t i;
        free (sgent->sg_name);
-       memzero (sgent->sg_passwd, strlen (sgent->sg_passwd));
-       free (sgent->sg_passwd);
-       while (NULL != *(sgent->sg_adm)) {
-               free (*(sgent->sg_adm));
-               sgent->sg_adm++;
+       if (NULL != sgent->sg_passwd) {
+               memzero (sgent->sg_passwd, strlen (sgent->sg_passwd));
+               free (sgent->sg_passwd);
        }
-       while (NULL != *(sgent->sg_mem)) {
-               free (*(sgent->sg_mem));
-               sgent->sg_mem++;
+       for (i = 0; NULL != sgent->sg_adm[i]; i++) {
+               free (sgent->sg_adm[i]);
+       }
+       free (sgent->sg_adm);
+       for (i = 0; NULL != sgent->sg_mem[i]; i++) {
+               free (sgent->sg_mem[i]);
        }
+       free (sgent->sg_mem);
        free (sgent);
 }
 
index a7a8592dd30a631472457f2b1be78bcd8ec2897a..2dece3830afb4c044d990ab50f88c4eeb9477e3e 100644 (file)
        if (NULL == sp) {
                return NULL;
        }
-       *sp = *spent;
-       sp->sp_namp = strdup (spent->sp_namp);
+       sp->sp_lstchg = spent->sp_lstchg;
+       sp->sp_min    = spent->sp_min;
+       sp->sp_max    = spent->sp_max;
+       sp->sp_warn   = spent->sp_warn;
+       sp->sp_inact  = spent->sp_inact;
+       sp->sp_expire = spent->sp_expire;
+       sp->sp_flag   = spent->sp_flag;
+       sp->sp_namp   = strdup (spent->sp_namp);
        if (NULL == sp->sp_namp) {
                free(sp);
                return NULL;
 void spw_free (/*@out@*/ /*@only@*/struct spwd *spent)
 {
        free (spent->sp_namp);
-       memzero (spent->sp_pwdp, strlen (spent->sp_pwdp));
-       free (spent->sp_pwdp);
+       if (NULL != spent->sp_pwdp) {
+               memzero (spent->sp_pwdp, strlen (spent->sp_pwdp));
+               free (spent->sp_pwdp);
+       }
        free (spent);
 }