[git commit] cryptpw: -m sha512crypt must also be accepted
Denys Vlasenko
vda.linux at googlemail.com
Mon Jul 7 15:42:35 UTC 2025
commit: https://git.busybox.net/busybox/commit/?id=5e9b95ff40de7e9b3395e51d456647ae99b2e8b2
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
libbb/pw_encrypt.c | 2 +-
testsuite/cryptpw.tests | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c
index 4acc33039..3b2fea00d 100644
--- a/libbb/pw_encrypt.c
+++ b/libbb/pw_encrypt.c
@@ -30,7 +30,7 @@ char* FAST_FUNC crypt_make_pw_salt(char salt[MAX_PW_SALT_LEN], const char *algo)
*salt_ptr++ = '$';
#if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA
if ((algo[0]|0x20) == 's') { /* sha */
- salt[1] = '5' + (strcasecmp(algo, "sha512") == 0);
+ salt[1] = '5' + (strncasecmp(algo, "sha512", 6) == 0);
len = 16 / 2;
}
#endif
diff --git a/testsuite/cryptpw.tests b/testsuite/cryptpw.tests
index ab8f32d8e..beac35efe 100755
--- a/testsuite/cryptpw.tests
+++ b/testsuite/cryptpw.tests
@@ -49,6 +49,10 @@ testing 'cryptpw sha512' \
'cryptpw -m sha512 QWErty 123456789012345678901234567890' \
'$6$1234567890123456$KB7QqxFyqmJSWyQYcCuGeFukgz1bPQoipWZf7.9L7z3k8UNTXa6UikbKcUGDc2ANn7DOGmDaroxDgpK16w/RE0\n' \
'' ''
+testing 'cryptpw sha512crypt' \
+ 'cryptpw -m sha512crypt QWErty 123456789012345678901234567890' \
+ '$6$1234567890123456$KB7QqxFyqmJSWyQYcCuGeFukgz1bPQoipWZf7.9L7z3k8UNTXa6UikbKcUGDc2ANn7DOGmDaroxDgpK16w/RE0\n' \
+ '' ''
testing 'cryptpw sha512 rounds=99999' \
'cryptpw -m sha512 QWErty rounds=99999\$123456789012345678901234567890' \
'$6$rounds=99999$1234567890123456$BfF6gD6ZjUmwawH5QaAglYAxtU./yvsz0fcQ464l49aMI2DZW3j5ri28CrxK7riPWNpLuUpfaIdY751SBYKUH.\n' \
More information about the busybox-cvs
mailing list