aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/connection.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-01-16 08:35:57 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-01-16 08:35:57 +0100
commitff030ebe25022bdb90cecb7bfe45c6f863e3be30 (patch)
tree036feae62e4879cf1b06868688630aa51d98ac9d /contrib/postgres_fdw/connection.c
parent965b2cc0a400bc0bc56525f8ae12ddd93c3d5bbd (diff)
downloadpostgresql-ff030ebe25022bdb90cecb7bfe45c6f863e3be30.tar.gz
postgresql-ff030ebe25022bdb90cecb7bfe45c6f863e3be30.zip
Check return of pg_b64_encode() for error
Forgotten in commit 761c79508e7. Author: Ranier Vilela <ranier.vf@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAEudQAq-3yHsSdWoOOaw%2BgAQYgPMpMGuB5pt2yCXgv-YuxG2Hg%40mail.gmail.com
Diffstat (limited to 'contrib/postgres_fdw/connection.c')
-rw-r--r--contrib/postgres_fdw/connection.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c
index 0274d6c253d..8a8d3b4481f 100644
--- a/contrib/postgres_fdw/connection.c
+++ b/contrib/postgres_fdw/connection.c
@@ -559,23 +559,28 @@ connect_pg_server(ForeignServer *server, UserMapping *user)
if (MyProcPort->has_scram_keys && UseScramPassthrough(server, user))
{
int len;
+ int encoded_len;
keywords[n] = "scram_client_key";
len = pg_b64_enc_len(sizeof(MyProcPort->scram_ClientKey));
/* don't forget the zero-terminator */
values[n] = palloc0(len + 1);
- pg_b64_encode((const char *) MyProcPort->scram_ClientKey,
- sizeof(MyProcPort->scram_ClientKey),
- (char *) values[n], len);
+ encoded_len = pg_b64_encode((const char *) MyProcPort->scram_ClientKey,
+ sizeof(MyProcPort->scram_ClientKey),
+ (char *) values[n], len);
+ if (encoded_len < 0)
+ elog(ERROR, "could not encode SCRAM client key");
n++;
keywords[n] = "scram_server_key";
len = pg_b64_enc_len(sizeof(MyProcPort->scram_ServerKey));
/* don't forget the zero-terminator */
values[n] = palloc0(len + 1);
- pg_b64_encode((const char *) MyProcPort->scram_ServerKey,
- sizeof(MyProcPort->scram_ServerKey),
- (char *) values[n], len);
+ encoded_len = pg_b64_encode((const char *) MyProcPort->scram_ServerKey,
+ sizeof(MyProcPort->scram_ServerKey),
+ (char *) values[n], len);
+ if (encoded_len < 0)
+ elog(ERROR, "could not encode SCRAM server key");
n++;
}