summaryrefslogtreecommitdiff
path: root/libcrypt
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-01-26 11:22:42 -0600
committerWaldemar Brodkorb <wbx@openadk.org>2015-01-26 11:22:42 -0600
commitf03fbbb009c0df52d363719a592e2ac33577d9a6 (patch)
tree01671bcc5099ef304faf5ae86d58bbf32f9d0b7c /libcrypt
parent97dc8cb71d96a4bbfda0aa51740433d5da825b6a (diff)
parent92de8a5f6ffb1ff9f7183fd08d872aa098b75ae2 (diff)
merge upstream changes
Diffstat (limited to 'libcrypt')
-rw-r--r--libcrypt/crypt.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libcrypt/crypt.c b/libcrypt/crypt.c
index f79c9fe8b..10061a073 100644
--- a/libcrypt/crypt.c
+++ b/libcrypt/crypt.c
@@ -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);
}