summaryrefslogtreecommitdiffstats
path: root/lib/libcrypt
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2014-05-28 16:50:18 +0000
committerume <ume@FreeBSD.org>2014-05-28 16:50:18 +0000
commitc6e6acd06489c458286705d33b7ead20a10e395e (patch)
tree6a2bb2593eadb7c165dc0896fc3edf3f3b90a8f1 /lib/libcrypt
parent0efc57102dd50bcbfa694b48d8564e37514848e3 (diff)
downloadFreeBSD-src-c6e6acd06489c458286705d33b7ead20a10e395e.zip
FreeBSD-src-c6e6acd06489c458286705d33b7ead20a10e395e.tar.gz
Don't break the legacy applications which set
just 2 bytes to salt. MFC after: 1 week
Diffstat (limited to 'lib/libcrypt')
-rw-r--r--lib/libcrypt/crypt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libcrypt/crypt.c b/lib/libcrypt/crypt.c
index 040fdc1..c3ca4c2 100644
--- a/lib/libcrypt/crypt.c
+++ b/lib/libcrypt/crypt.c
@@ -104,12 +104,16 @@ char *
crypt(const char *passwd, const char *salt)
{
const struct crypt_format *cf;
+#ifdef HAS_DES
+ int len;
+#endif
for (cf = crypt_formats; cf->name != NULL; ++cf)
if (cf->magic != NULL && strstr(salt, cf->magic) == salt)
return (cf->func(passwd, salt));
#ifdef HAS_DES
- if (strlen(salt) == 13 && strspn(salt, DES_SALT_ALPHABET) == 13)
+ len = strlen(salt);
+ if ((len == 13 || len == 2) && strspn(salt, DES_SALT_ALPHABET) == len)
return (crypt_des(passwd, salt));
#endif
return (crypt_format->func(passwd, salt));
OpenPOWER on IntegriCloud