From 29dd2e253c74c7ab2fed6fb6a67a87089197253f Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 5 Jul 2023 08:00:00 +0000 Subject: [PATCH] pwquality: fix use of ERRNO_IS_NOT_SUPPORTED 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/shared/pwquality-util.c b/src/shared/pwquality-util.c index 839cf4caf9..5deb9324ae 100644 --- a/src/shared/pwquality-util.c +++ b/src/shared/pwquality-util.c @@ -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) { -- 2.25.1