aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--loginutils/passwd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 611ced3a4..a1ad02bf0 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -322,6 +322,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
322 char *clear; 322 char *clear;
323 char *cipher; 323 char *cipher;
324 char *cp; 324 char *cp;
325 char salt[12]; /* "$N$XXXXXXXX" or "XX" */
325 char orig[200]; 326 char orig[200];
326 char pass[200]; 327 char pass[200];
327 328
@@ -376,11 +377,18 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
376 } 377 }
377 memset(cp, 0, strlen(cp)); 378 memset(cp, 0, strlen(cp));
378 memset(orig, 0, sizeof(orig)); 379 memset(orig, 0, sizeof(orig));
380 memset(salt, 0, sizeof(salt));
379 381
380 if (algo == 1) { 382 if (algo == 1) {
381 cp = pw_encrypt(pass, "$1$"); 383 strcpy(salt, "$1$");
382 } else 384 strcat(salt, crypt_make_salt());
383 cp = pw_encrypt(pass, crypt_make_salt()); 385 strcat(salt, crypt_make_salt());
386 strcat(salt, crypt_make_salt());
387 }
388
389 strcat(salt, crypt_make_salt());
390 cp = pw_encrypt(pass, salt);
391
384 memset(pass, 0, sizeof pass); 392 memset(pass, 0, sizeof pass);
385 safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); 393 safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd));
386 return 0; 394 return 0;