]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Make test_password_{one,many} also use crypt_ra()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Sep 2020 14:27:47 +0000 (16:27 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 15 Sep 2020 09:52:30 +0000 (11:52 +0200)
src/shared/libcrypt-util.c

index 1faf683d715bc8fc3921c399ce37ffa6cc35cc24..a2f5f06bcc4c3fd198a1b024d93829140777c1e6 100644 (file)
@@ -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) {