* libmisc/obscure.c, libmisc/salt.c, src/passwd.c: Match DES, MD5,
SHA256, and SHA512 exactly (not only the first 3/6 chars). * libmisc/salt.c (SHA_salt_rounds): Set rounds to the specified prefered_rounds value, if specified. * src/gpasswd.c, libmisc/salt.c: Fix compilation warnings (use size_t for lengths). * src/chpasswd.c, src/chgpasswd.c: Add missing parenthesis.
This commit is contained in:
@@ -49,6 +49,29 @@ char *pw_encrypt (const char *clear, const char *salt)
|
||||
perror ("crypt");
|
||||
exit (1);
|
||||
}
|
||||
if (salt && salt[0] == '$' && strlen (cp) <= 13)
|
||||
{
|
||||
/* The crypt algorithm was not recognized by libcrypt */
|
||||
char *method = "$1$";
|
||||
switch (salt[1])
|
||||
{
|
||||
case '1':
|
||||
method = "MD5";
|
||||
break;
|
||||
case '5':
|
||||
method = "SHA256";
|
||||
break;
|
||||
case '6':
|
||||
method = "SHA512";
|
||||
break;
|
||||
default:
|
||||
method[1] = salt[1];
|
||||
}
|
||||
fprintf (stderr,
|
||||
_("Unknown crypt method (%s)\n"),
|
||||
method);
|
||||
exit (1);
|
||||
}
|
||||
if (strlen (cp) != 13)
|
||||
return cp; /* nonstandard crypt() in libc, better bail out */
|
||||
strcpy (cipher, cp);
|
||||
|
Reference in New Issue
Block a user