Skip to content

Commit e0a09d4

Browse files
committed
Fix inconsistent error handling for GSS encryption in PQconnectPoll()
The error cases for TLS and GSS encryption were inconsistent. After TLS fails, the connection is marked as dead and follow-up calls of PQconnectPoll() would return immediately, but GSS encryption was not doing that, so the connection would still have been allowed to enter the GSS handling code. This was handled incorrectly when gssencmode was set to "require". "prefer" was working correctly, and this could not happen under "disable" as GSS encryption would not be attempted. This commit makes the error handling of GSS encryption on par with TLS portion, fixing the case of gssencmode=require. Reported-by: Jacob Champion Author: Michael Paquier Reviewed-by: Jacob Champion, Stephen Frost Discussion: https://postgr.es/m/23787477-5fe1-a161-6d2a-e459f74c4713@timescale.com Backpatch-through: 12
1 parent bf32ec2 commit e0a09d4

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/interfaces/libpq/fe-connect.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -3148,17 +3148,22 @@ PQconnectPoll(PGconn *conn)
31483148
conn->status = CONNECTION_MADE;
31493149
return PGRES_POLLING_WRITING;
31503150
}
3151-
else if (pollres == PGRES_POLLING_FAILED &&
3152-
conn->gssencmode[0] == 'p')
3151+
else if (pollres == PGRES_POLLING_FAILED)
31533152
{
3154-
/*
3155-
* We failed, but we can retry on "prefer". Have to drop
3156-
* the current connection to do so, though.
3157-
*/
3158-
conn->try_gss = false;
3159-
need_new_connection = true;
3160-
goto keep_going;
3153+
if (conn->gssencmode[0] == 'p')
3154+
{
3155+
/*
3156+
* We failed, but we can retry on "prefer". Have to
3157+
* drop the current connection to do so, though.
3158+
*/
3159+
conn->try_gss = false;
3160+
need_new_connection = true;
3161+
goto keep_going;
3162+
}
3163+
/* Else it's a hard failure */
3164+
goto error_return;
31613165
}
3166+
/* Else, return POLLING_READING or POLLING_WRITING status */
31623167
return pollres;
31633168
#else /* !ENABLE_GSS */
31643169
/* unreachable */

0 commit comments

Comments
 (0)