Skip to content

Commit 96bef43

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 baf7f45 commit 96bef43

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,17 +3210,22 @@ PQconnectPoll(PGconn *conn)
32103210
conn->status = CONNECTION_MADE;
32113211
return PGRES_POLLING_WRITING;
32123212
}
3213-
else if (pollres == PGRES_POLLING_FAILED &&
3214-
conn->gssencmode[0] == 'p')
3213+
else if (pollres == PGRES_POLLING_FAILED)
32153214
{
3216-
/*
3217-
* We failed, but we can retry on "prefer". Have to drop
3218-
* the current connection to do so, though.
3219-
*/
3220-
conn->try_gss = false;
3221-
need_new_connection = true;
3222-
goto keep_going;
3215+
if (conn->gssencmode[0] == 'p')
3216+
{
3217+
/*
3218+
* We failed, but we can retry on "prefer". Have to
3219+
* drop the current connection to do so, though.
3220+
*/
3221+
conn->try_gss = false;
3222+
need_new_connection = true;
3223+
goto keep_going;
3224+
}
3225+
/* Else it's a hard failure */
3226+
goto error_return;
32233227
}
3228+
/* Else, return POLLING_READING or POLLING_WRITING status */
32243229
return pollres;
32253230
#else /* !ENABLE_GSS */
32263231
/* unreachable */

0 commit comments

Comments
 (0)