summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-auth.c
diff options
context:
space:
mode:
authorHeikki Linnakangas2017-03-07 17:00:22 +0000
committerHeikki Linnakangas2017-03-07 17:00:22 +0000
commit95c1dbcdfffcc3a77e693c3c2759e26a01f465c8 (patch)
treed671488f0ef3412fd108b73625fc41d1f7aac18a /src/interfaces/libpq/fe-auth.c
parent3bc7dafa9bebbdaa1bbf0da0798d29a8bdaf6a8f (diff)
A collection of small fixes for the SCRAM patch.
* Add required #includes for htonl. Per buildfarm members pademelon/gaur. * Remove unnecessary "#include <utils/memutils>". * Fix checking for empty string in pg_SASL_init. (Reported by Peter Eisentraut and his compiler) * Move code in pg_SASL_init to match the recent changes (commit ba005f193d) to pg_fe_sendauth() function, where it's copied from. * Return value of malloc() was not checked for NULL in scram_SaltedPassword(). Fix by avoiding the malloc().
Diffstat (limited to 'src/interfaces/libpq/fe-auth.c')
-rw-r--r--src/interfaces/libpq/fe-auth.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index c69260b5226..5fe7e565a01 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -445,12 +445,13 @@ pg_SASL_init(PGconn *conn, const char *auth_mechanism)
*/
if (strcmp(auth_mechanism, SCRAM_SHA256_NAME) == 0)
{
- char *password = conn->connhost[conn->whichhost].password;
+ char *password;
+ conn->password_needed = true;
+ password = conn->connhost[conn->whichhost].password;
if (password == NULL)
password = conn->pgpass;
- conn->password_needed = true;
- if (password == NULL || password == '\0')
+ if (password == NULL || password[0] == '\0')
{
printfPQExpBuffer(&conn->errorMessage,
PQnoPasswordSupplied);