samba-cvs.cvs
[Top] [All Lists]

svn commit: samba r13525 - branches/SAMBA_3_0/source/utils trunk/source/

Subject: svn commit: samba r13525 - branches/SAMBA_3_0/source/utils trunk/source/utils
From:
Date: Thu, 16 Feb 2006 16:45:59 +0000 GMT
Author: lmuelle
Date: 2006-02-16 16:45:58 +0000 (Thu, 16 Feb 2006)
New Revision: 13525

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13525

Log:
This is only a cleanup to have the memset() and SAFE_FREE() only one
time in the code.

Even if we now have an additional if statement after the free I prefer
this solution in opposite to the duplicated code we had before.

Modified:
   branches/SAMBA_3_0/source/utils/pdbedit.c
   trunk/source/utils/pdbedit.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/pdbedit.c
===================================================================
--- branches/SAMBA_3_0/source/utils/pdbedit.c   2006-02-16 16:22:44 UTC (rev 
13524)
+++ branches/SAMBA_3_0/source/utils/pdbedit.c   2006-02-16 16:45:58 UTC (rev 
13525)
@@ -400,6 +400,7 @@
        SAM_ACCOUNT *sam_pwent=NULL;
 
        char *password1, *password2;
+       int rc_pwd_cmp;
 
        get_global_sam_sid();
 
@@ -410,22 +411,22 @@
 
        password1 = get_pass( "new password:", stdin_get);
        password2 = get_pass( "retype new password:", stdin_get);
-       if (strcmp (password1, password2)) {
-               fprintf (stderr, "Passwords does not match!\n");
-               memset(password1, 0, strlen(password1));
-               SAFE_FREE(password1);
-               memset(password2, 0, strlen(password2));
-               SAFE_FREE(password2);
+       if ((rc_pwd_cmp = strcmp (password1, password2))) {
+               fprintf (stderr, "Passwords do not match!\n");
                pdb_free_sam (&sam_pwent);
-               return -1;
+       } else {
+               pdb_set_plaintext_passwd(sam_pwent, password1);
        }
 
-       pdb_set_plaintext_passwd(sam_pwent, password1);
        memset(password1, 0, strlen(password1));
        SAFE_FREE(password1);
        memset(password2, 0, strlen(password2));
        SAFE_FREE(password2);
 
+       /* pwds do _not_ match? */
+       if (rc_pwd_cmp)
+               return -1;
+
        if (fullname)
                pdb_set_fullname(sam_pwent, fullname, PDB_CHANGED);
        if (homedir)

Modified: trunk/source/utils/pdbedit.c
===================================================================
--- trunk/source/utils/pdbedit.c        2006-02-16 16:22:44 UTC (rev 13524)
+++ trunk/source/utils/pdbedit.c        2006-02-16 16:45:58 UTC (rev 13525)
@@ -400,6 +400,7 @@
        SAM_ACCOUNT *sam_pwent=NULL;
 
        char *password1, *password2;
+       int rc_pwd_cmp;
 
        get_global_sam_sid();
 
@@ -410,22 +411,22 @@
 
        password1 = get_pass( "new password:", stdin_get);
        password2 = get_pass( "retype new password:", stdin_get);
-       if (strcmp (password1, password2)) {
-               fprintf (stderr, "Passwords does not match!\n");
-               memset(password1, 0, strlen(password1));
-               SAFE_FREE(password1);
-               memset(password2, 0, strlen(password2));
-               SAFE_FREE(password2);
+       if ((rc_pwd_cmp = strcmp (password1, password2))) {
+               fprintf (stderr, "Passwords do not match!\n");
                pdb_free_sam (&sam_pwent);
-               return -1;
+       } else {
+               pdb_set_plaintext_passwd(sam_pwent, password1);
        }
 
-       pdb_set_plaintext_passwd(sam_pwent, password1);
        memset(password1, 0, strlen(password1));
        SAFE_FREE(password1);
        memset(password2, 0, strlen(password2));
        SAFE_FREE(password2);
 
+       /* pwds do _not_ match? */
+       if (rc_pwd_cmp)
+               return -1;
+
        if (fullname)
                pdb_set_fullname(sam_pwent, fullname, PDB_CHANGED);
        if (homedir)

<Prev in Thread] Current Thread [Next in Thread>
  • svn commit: samba r13525 - branches/SAMBA_3_0/source/utils trunk/source/utils, lmuelle <=