1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-02 11:44:50 +03:00

Fix bogus order of error checks in new channel_binding code.

Coverity pointed out that it's pretty silly to check for a null pointer
after we've already dereferenced the pointer.  To fix, just swap the
order of the two error checks.  Oversight in commit d6e612f83.
This commit is contained in:
Tom Lane 2019-09-29 12:35:53 -04:00
parent 92f1545d6e
commit 2c97f73468

View File

@ -502,6 +502,13 @@ pg_SASL_init(PGconn *conn, int payloadlen)
selected_mechanism = SCRAM_SHA_256_NAME; selected_mechanism = SCRAM_SHA_256_NAME;
} }
if (!selected_mechanism)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("none of the server's SASL authentication mechanisms are supported\n"));
goto error;
}
if (conn->channel_binding[0] == 'r' && /* require */ if (conn->channel_binding[0] == 'r' && /* require */
strcmp(selected_mechanism, SCRAM_SHA_256_PLUS_NAME) != 0) strcmp(selected_mechanism, SCRAM_SHA_256_PLUS_NAME) != 0)
{ {
@ -510,13 +517,6 @@ pg_SASL_init(PGconn *conn, int payloadlen)
goto error; goto error;
} }
if (!selected_mechanism)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("none of the server's SASL authentication mechanisms are supported\n"));
goto error;
}
/* /*
* Now that the SASL mechanism has been chosen for the exchange, * Now that the SASL mechanism has been chosen for the exchange,
* initialize its state information. * initialize its state information.