Skip to content

Commit 9cb5518

Browse files
committed
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 b69aba7. Like that one, back-patch to v14.
1 parent 790fbda commit 9cb5518

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/interfaces/libpq/fe-auth.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,10 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
12901290
if (strcmp(algorithm, "scram-sha-256") == 0)
12911291
{
12921292
crypt_pwd = pg_fe_scram_build_secret(passwd);
1293+
/* We assume the only possible failure is OOM */
1294+
if (!crypt_pwd)
1295+
appendPQExpBufferStr(&conn->errorMessage,
1296+
libpq_gettext("out of memory\n"));
12931297
}
12941298
else if (strcmp(algorithm, "md5") == 0)
12951299
{
@@ -1307,6 +1311,9 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
13071311
crypt_pwd = NULL;
13081312
}
13091313
}
1314+
else
1315+
appendPQExpBufferStr(&conn->errorMessage,
1316+
libpq_gettext("out of memory\n"));
13101317
}
13111318
else
13121319
{
@@ -1316,9 +1323,5 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
13161323
return NULL;
13171324
}
13181325

1319-
if (!crypt_pwd)
1320-
appendPQExpBufferStr(&conn->errorMessage,
1321-
libpq_gettext("out of memory\n"));
1322-
13231326
return crypt_pwd;
13241327
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy