From: Zbigniew Jędrzejewski-Szmek Date: Tue, 8 Sep 2020 14:27:47 +0000 (+0200) Subject: Make test_password_{one,many} also use crypt_ra() X-Git-Tag: v247-rc1~204^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=999b49c818f5ae28d24fe7a551542e945130dcb3;p=thirdparty%2Fsystemd.git Make test_password_{one,many} also use crypt_ra() --- diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index 1faf683d715..a2f5f06bcc4 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -119,20 +119,16 @@ bool looks_like_hashed_password(const char *s) { } int test_password_one(const char *hashed_password, const char *password) { - struct crypt_data cc = {}; + _cleanup_(erase_and_freep) void *cd_data = NULL; + int cd_size = 0; const char *k; - bool b; errno = 0; - k = crypt_r(password, hashed_password, &cc); - if (!k) { - explicit_bzero_safe(&cc, sizeof(cc)); + k = crypt_ra(password, hashed_password, &cd_data, &cd_size); + if (!k) return errno_or_else(EINVAL); - } - b = streq(k, hashed_password); - explicit_bzero_safe(&cc, sizeof(cc)); - return b; + return streq(k, hashed_password); } int test_password_many(char **hashed_password, const char *password) {