Skip to content

Commit ab27df2

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 3a0cced commit ab27df2

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
@@ -1265,6 +1265,10 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
12651265
if (strcmp(algorithm, "scram-sha-256") == 0)
12661266
{
12671267
crypt_pwd = pg_fe_scram_build_secret(passwd);
1268+
/* We assume the only possible failure is OOM */
1269+
if (!crypt_pwd)
1270+
appendPQExpBufferStr(&conn->errorMessage,
1271+
libpq_gettext("out of memory\n"));
12681272
}
12691273
else if (strcmp(algorithm, "md5") == 0)
12701274
{
@@ -1282,6 +1286,9 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
12821286
crypt_pwd = NULL;
12831287
}
12841288
}
1289+
else
1290+
appendPQExpBufferStr(&conn->errorMessage,
1291+
libpq_gettext("out of memory\n"));
12851292
}
12861293
else
12871294
{
@@ -1291,9 +1298,5 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
12911298
return NULL;
12921299
}
12931300

1294-
if (!crypt_pwd)
1295-
appendPQExpBufferStr(&conn->errorMessage,
1296-
libpq_gettext("out of memory\n"));
1297-
12981301
return crypt_pwd;
12991302
}

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