diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-07 17:42:35 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-07 17:42:35 +0200 |
| commit | 5e9b95ff40de7e9b3395e51d456647ae99b2e8b2 (patch) | |
| tree | 6818f8460fea1bced80573accf7381198bdefa16 | |
| parent | 479d8db99faa005783fc483d0830314d6156e51f (diff) | |
cryptpw: -m sha512crypt must also be accepted
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | libbb/pw_encrypt.c | 2 | ||||
| -rwxr-xr-x | testsuite/cryptpw.tests | 4 |
2 files changed, 5 insertions, 1 deletions
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' \ |
