diff options
author | Bernhard Reutner-Fischer | 2006-05-19 10:13:09 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer | 2006-05-19 10:13:09 +0000 |
commit | cc8e90d1fbaad77ba6748635792aad7121c212bb (patch) | |
tree | 421336b4721fbf73758c23ceb209be69b8b86abf | |
parent | 158ffd405e3dace1c79cbbd6994d5b4936bfcd99 (diff) | |
download | busybox-cc8e90d1fbaad77ba6748635792aad7121c212bb.zip busybox-cc8e90d1fbaad77ba6748635792aad7121c212bb.tar.gz |
- passwd doesnt use salt with md5 passwords; bug #604 thanks taviso
(r14930 from trunk)
-rw-r--r-- | loginutils/passwd.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index 611ced3..a1ad02b 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) char *clear; char *cipher; char *cp; + char salt[12]; /* "$N$XXXXXXXX" or "XX" */ char orig[200]; char pass[200]; @@ -376,11 +377,18 @@ static int new_password(const struct passwd *pw, int amroot, int algo) } memset(cp, 0, strlen(cp)); memset(orig, 0, sizeof(orig)); + memset(salt, 0, sizeof(salt)); if (algo == 1) { - cp = pw_encrypt(pass, "$1$"); - } else - cp = pw_encrypt(pass, crypt_make_salt()); + strcpy(salt, "$1$"); + strcat(salt, crypt_make_salt()); + strcat(salt, crypt_make_salt()); + strcat(salt, crypt_make_salt()); + } + + strcat(salt, crypt_make_salt()); + cp = pw_encrypt(pass, salt); + memset(pass, 0, sizeof pass); safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); return 0; |