summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-07-19 18:17:24 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-07-19 18:20:01 +0200
commit6979467a62c4bc58eeede0436d06c0cd57649705 (patch)
treec9821a5faf01f066564574d20b51c3cc7252be93 /libbb
parent51b45ce28a6a5bbc035b200f170d520f94b7e59f (diff)
cryptpw: fix detection of crypt algo from salt (was broken if default isn't DES)
The symptom is: "cryptpw ... implicit" testsuite tests were failing if CONFIG_FEATURE_DEFAULT_PASSWD_ALGO is not "des". function old new delta cryptpw_main 223 283 +60 pw_encrypt 974 975 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 61/0) Total: 61 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/pw_encrypt.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c
index 3b2fea00d..56191b00e 100644
--- a/libbb/pw_encrypt.c
+++ b/libbb/pw_encrypt.c
@@ -37,9 +37,8 @@ char* FAST_FUNC crypt_make_pw_salt(char salt[MAX_PW_SALT_LEN], const char *algo)
#if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_YES
if ((algo[0]|0x20) == 'y') { /* yescrypt */
salt[1] = 'y';
- len = 24 / 2;
+ len = 22 / 2;
// The "j9T$" below is the default "yescrypt parameters" encoded by yescrypt_encode_params_r():
-//
//shadow-4.17.4/src/passwd.c
// salt = crypt_make_salt(NULL, NULL);
//shadow-4.17.4/lib/salt.c
@@ -105,14 +104,14 @@ static char *my_crypt(const char *key, const char *salt)
if (salt[0] == '$' && salt[1] && salt[2] == '$') {
if (salt[1] == '1')
return md5_crypt(xzalloc(MD5_OUT_BUFSIZE), (unsigned char*)key, (unsigned char*)salt);
-#if ENABLE_USE_BB_CRYPT_YES
- if (salt[1] == 'y')
- return yes_crypt(key, salt);
-#endif
#if ENABLE_USE_BB_CRYPT_SHA
if (salt[1] == '5' || salt[1] == '6')
return sha_crypt((char*)key, (char*)salt);
#endif
+#if ENABLE_USE_BB_CRYPT_YES
+ if (salt[1] == 'y')
+ return yes_crypt(key, salt);
+#endif
}
if (!des_cctx)