aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-01-11 12:03:06 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2022-01-11 12:03:06 -0500
commitab27df2490e3a5dfb8ecb3de66818d16645ef3dd (patch)
treebcc41f9ad8d1c7adf3e496b4577a02e41ec9df97 /src
parent3a0cced86d3b1bbbf0aaa0fb34e2b15edd643979 (diff)
downloadpostgresql-ab27df2490e3a5dfb8ecb3de66818d16645ef3dd.tar.gz
postgresql-ab27df2490e3a5dfb8ecb3de66818d16645ef3dd.zip
Clean up error message reported after \password encryption failure.
Experimenting with FIPS mode enabled, I saw regression=# \password joe Enter new password for user "joe": Enter it again: could not encrypt password: disabled for FIPS out of memory because PQencryptPasswordConn was still of the opinion that "out of memory" is always appropriate to print. Minor oversight in b69aba745. Like that one, back-patch to v14.
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/fe-auth.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 24927fd040f..5d0aaa8536b 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -1265,6 +1265,10 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
if (strcmp(algorithm, "scram-sha-256") == 0)
{
crypt_pwd = pg_fe_scram_build_secret(passwd);
+ /* We assume the only possible failure is OOM */
+ if (!crypt_pwd)
+ appendPQExpBufferStr(&conn->errorMessage,
+ libpq_gettext("out of memory\n"));
}
else if (strcmp(algorithm, "md5") == 0)
{
@@ -1282,6 +1286,9 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
crypt_pwd = NULL;
}
}
+ else
+ appendPQExpBufferStr(&conn->errorMessage,
+ libpq_gettext("out of memory\n"));
}
else
{
@@ -1291,9 +1298,5 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
return NULL;
}
- if (!crypt_pwd)
- appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory\n"));
-
return crypt_pwd;
}