summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Müller <lmuelle@samba.org>2006-02-16 16:45:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:10:10 -0500
commit4272419b1146b1c03e070655f3a31d027c00ad20 (patch)
tree7f1bc31c0a3e52e7b7a44978ac035b1571ba5676
parentdbdc5ba497c6010dbad47c9d77fc8bec5557a328 (diff)
downloadsamba-4272419b1146b1c03e070655f3a31d027c00ad20.tar.gz
samba-4272419b1146b1c03e070655f3a31d027c00ad20.tar.xz
samba-4272419b1146b1c03e070655f3a31d027c00ad20.zip
r13525: 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.
-rw-r--r--source/utils/pdbedit.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c
index 1423d9486d5..a098039cd07 100644
--- a/source/utils/pdbedit.c
+++ b/source/utils/pdbedit.c
@@ -400,6 +400,7 @@ static int new_user (struct pdb_methods *in, const char *username,
SAM_ACCOUNT *sam_pwent=NULL;
char *password1, *password2;
+ int rc_pwd_cmp;
get_global_sam_sid();
@@ -410,22 +411,22 @@ static int new_user (struct pdb_methods *in, const char *username,
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)