aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-19 10:13:09 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-19 10:13:09 +0000
commitcc8e90d1fbaad77ba6748635792aad7121c212bb (patch)
tree421336b4721fbf73758c23ceb209be69b8b86abf
parent158ffd405e3dace1c79cbbd6994d5b4936bfcd99 (diff)
downloadbusybox-w32-cc8e90d1fbaad77ba6748635792aad7121c212bb.tar.gz
busybox-w32-cc8e90d1fbaad77ba6748635792aad7121c212bb.tar.bz2
busybox-w32-cc8e90d1fbaad77ba6748635792aad7121c212bb.zip
- passwd doesnt use salt with md5 passwords; bug #604 thanks taviso
(r14930 from trunk)
-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;