]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pwquality: fix use of ERRNO_IS_NOT_SUPPORTED
authorDmitry V. Levin <ldv@strace.io>
Wed, 5 Jul 2023 08:00:00 +0000 (08:00 +0000)
committerDmitry V. Levin <ldv@strace.io>
Thu, 6 Jul 2023 10:59:41 +0000 (10:59 +0000)
Given that ERRNO_IS_*() also match positive values, call
ERRNO_IS_NOT_SUPPORTED() only if the value returned by
pwq_allocate_context() is negative.

src/shared/pwquality-util.c

index 839cf4caf997d91a5382236987e7c968b040842a..5deb9324aec301189c58c709388810096662d514 100644 (file)
@@ -107,10 +107,11 @@ int suggest_passwords(void) {
         int r;
 
         r = pwq_allocate_context(&pwq);
-        if (ERRNO_IS_NOT_SUPPORTED(r))
-                return 0;
-        if (r < 0)
+        if (r < 0) {
+                if (ERRNO_IS_NOT_SUPPORTED(r))
+                        return 0;
                 return log_error_errno(r, "Failed to allocate libpwquality context: %m");
+        }
 
         suggestions = new0(char*, N_SUGGESTIONS+1);
         if (!suggestions)
@@ -140,10 +141,11 @@ int quality_check_password(const char *password, const char *username, char **re
         assert(password);
 
         r = pwq_allocate_context(&pwq);
-        if (ERRNO_IS_NOT_SUPPORTED(r))
-                return 0;
-        if (r < 0)
+        if (r < 0) {
+                if (ERRNO_IS_NOT_SUPPORTED(r))
+                        return 0;
                 return log_debug_errno(r, "Failed to allocate libpwquality context: %m");
+        }
 
         r = sym_pwquality_check(pwq, password, NULL, username, &auxerror);
         if (r < 0) {