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.
This commit is contained in:
Dmitry V. Levin 2023-07-05 08:00:00 +00:00
parent 5bc9ea070f
commit 29dd2e253c

View 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) {