From: Dmitry V. Levin Date: Wed, 5 Jul 2023 08:00:00 +0000 (+0000) Subject: pwquality: fix use of ERRNO_IS_NOT_SUPPORTED X-Git-Tag: v254-rc1~7^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29dd2e253c74c7ab2fed6fb6a67a87089197253f;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/pwquality-util.c b/src/shared/pwquality-util.c index 839cf4caf99..5deb9324aec 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) {