Skip to content

Commit bc20a13

Browse files
ldv-altbluca
authored andcommitted
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. (cherry picked from commit 29dd2e2) (cherry picked from commit ac531ec) (cherry picked from commit c43fef1)
1 parent dd15045 commit bc20a13

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/shared/pwquality-util.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ int suggest_passwords(void) {
111111
int r;
112112

113113
r = pwq_allocate_context(&pwq);
114-
if (ERRNO_IS_NOT_SUPPORTED(r))
115-
return 0;
116-
if (r < 0)
114+
if (r < 0) {
115+
if (ERRNO_IS_NOT_SUPPORTED(r))
116+
return 0;
117117
return log_error_errno(r, "Failed to allocate libpwquality context: %m");
118+
}
118119

119120
suggestions = new0(char*, N_SUGGESTIONS+1);
120121
if (!suggestions)
@@ -144,10 +145,11 @@ int quality_check_password(const char *password, const char *username, char **re
144145
assert(password);
145146

146147
r = pwq_allocate_context(&pwq);
147-
if (ERRNO_IS_NOT_SUPPORTED(r))
148-
return 0;
149-
if (r < 0)
148+
if (r < 0) {
149+
if (ERRNO_IS_NOT_SUPPORTED(r))
150+
return 0;
150151
return log_debug_errno(r, "Failed to allocate libpwquality context: %m");
152+
}
151153

152154
r = sym_pwquality_check(pwq, password, NULL, username, &auxerror);
153155
if (r < 0) {

0 commit comments

Comments
 (0)