Skip to content

Commit aaf09c5

Browse files
committed
Avoid masking EOF (no-password-supplied) conditions in auth.c.
CheckPWChallengeAuth() would return STATUS_ERROR if the user does not exist or has no password assigned, even if the client disconnected without responding to the password challenge (as libpq often will, for example). We should return STATUS_EOF in that case, and the lower-level functions do, but this code level got it wrong since the refactoring done in 7ac955b. This breaks the intent of not logging anything for EOF cases (cf. comments in auth_failed()) and might also confuse users of ClientAuthentication_hook. Per report from Liu Lang. Back-patch to all supported versions. Discussion: https://postgr.es/m/[email protected]
1 parent 59fd390 commit aaf09c5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Diff for: src/backend/libpq/auth.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -865,15 +865,13 @@ CheckPWChallengeAuth(Port *port, const char **logdetail)
865865

866866
if (shadow_pass)
867867
pfree(shadow_pass);
868-
869-
/*
870-
* If get_role_password() returned error, return error, even if the
871-
* authentication succeeded.
872-
*/
873-
if (!shadow_pass)
868+
else
874869
{
870+
/*
871+
* If get_role_password() returned error, authentication better not
872+
* have succeeded.
873+
*/
875874
Assert(auth_result != STATUS_OK);
876-
return STATUS_ERROR;
877875
}
878876

879877
if (auth_result == STATUS_OK)

0 commit comments

Comments
 (0)