mirror of
https://git.busybox.net/uClibc
synced 2025-10-14 01:32:00 +08:00
libcrypt: return NULL on unsupported salt
BZ #7808 asks us not to fallback to DES if the optional SHA are disabled but requested by the user. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
This commit is contained in:
@@ -14,17 +14,21 @@ char *crypt(const char *key, const char *salt)
|
||||
const unsigned char *ukey = (const unsigned char *)key;
|
||||
const unsigned char *usalt = (const unsigned char *)salt;
|
||||
|
||||
if (salt[0] == '$' && salt[2] == '$') {
|
||||
if (*++salt == '1')
|
||||
return __md5_crypt(ukey, usalt);
|
||||
if (salt[0] == '$') {
|
||||
if (salt[1] && salt[2] == '$') { /* no blowfish '2X' here ATM */
|
||||
if (*++salt == '1')
|
||||
return __md5_crypt(ukey, usalt);
|
||||
#ifdef __UCLIBC_HAS_SHA256_CRYPT_IMPL__
|
||||
else if (*salt == '5')
|
||||
return __sha256_crypt(ukey, usalt);
|
||||
else if (*salt == '5')
|
||||
return __sha256_crypt(ukey, usalt);
|
||||
#endif
|
||||
#ifdef __UCLIBC_HAS_SHA512_CRYPT_IMPL__
|
||||
else if (*salt == '6')
|
||||
return __sha512_crypt(ukey, usalt);
|
||||
else if (*salt == '6')
|
||||
return __sha512_crypt(ukey, usalt);
|
||||
#endif
|
||||
}
|
||||
/* __set_errno(EINVAL);*/ /* ENOSYS might be misleading */
|
||||
return NULL;
|
||||
}
|
||||
return __des_crypt(ukey, usalt);
|
||||
}
|
||||
|
Reference in New Issue
Block a user