diff options
| author | Heikki Linnakangas | 2025-05-08 19:01:25 +0000 |
|---|---|---|
| committer | Heikki Linnakangas | 2025-05-08 19:01:25 +0000 |
| commit | b28c59a6cd089902e66a91e0d0974da34d1c922b (patch) | |
| tree | b114ea0f8fa89e2251b80ef7ba13a04ef0a25891 /contrib | |
| parent | 965213d9c56a671086525a65f5427653b4a66350 (diff) | |
Use 'void *' for arbitrary buffers, 'uint8 *' for byte arrays
A 'void *' argument suggests that the caller might pass an arbitrary
struct, which is appropriate for functions like libc's read/write, or
pq_sendbytes(). 'uint8 *' is more appropriate for byte arrays that
have no structure, like the cancellation keys or SCRAM tokens. Some
places used 'char *', but 'uint8 *' is better because 'char *' is
commonly used for null-terminated strings. Change code around SCRAM,
MD5 authentication, and cancellation key handling to follow these
conventions.
Discussion: https://www.postgresql.org/message-id/61be9e31-7b7d-49d5-bc11-721800d89d64@eisentraut.org
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/dblink/dblink.c | 4 | ||||
| -rw-r--r-- | contrib/postgres_fdw/connection.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 1b2d72c6def..98d4e3d7dac 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -3218,7 +3218,7 @@ appendSCRAMKeysInfo(StringInfo buf) len = pg_b64_enc_len(sizeof(MyProcPort->scram_ClientKey)); /* don't forget the zero-terminator */ client_key = palloc0(len + 1); - encoded_len = pg_b64_encode((const char *) MyProcPort->scram_ClientKey, + encoded_len = pg_b64_encode(MyProcPort->scram_ClientKey, sizeof(MyProcPort->scram_ClientKey), client_key, len); if (encoded_len < 0) @@ -3227,7 +3227,7 @@ appendSCRAMKeysInfo(StringInfo buf) len = pg_b64_enc_len(sizeof(MyProcPort->scram_ServerKey)); /* don't forget the zero-terminator */ server_key = palloc0(len + 1); - encoded_len = pg_b64_encode((const char *) MyProcPort->scram_ServerKey, + encoded_len = pg_b64_encode(MyProcPort->scram_ServerKey, sizeof(MyProcPort->scram_ServerKey), server_key, len); if (encoded_len < 0) diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c index 9fa7f7e95cd..304f3c20f83 100644 --- a/contrib/postgres_fdw/connection.c +++ b/contrib/postgres_fdw/connection.c @@ -577,7 +577,7 @@ connect_pg_server(ForeignServer *server, UserMapping *user) len = pg_b64_enc_len(sizeof(MyProcPort->scram_ClientKey)); /* don't forget the zero-terminator */ values[n] = palloc0(len + 1); - encoded_len = pg_b64_encode((const char *) MyProcPort->scram_ClientKey, + encoded_len = pg_b64_encode(MyProcPort->scram_ClientKey, sizeof(MyProcPort->scram_ClientKey), (char *) values[n], len); if (encoded_len < 0) @@ -588,7 +588,7 @@ connect_pg_server(ForeignServer *server, UserMapping *user) len = pg_b64_enc_len(sizeof(MyProcPort->scram_ServerKey)); /* don't forget the zero-terminator */ values[n] = palloc0(len + 1); - encoded_len = pg_b64_encode((const char *) MyProcPort->scram_ServerKey, + encoded_len = pg_b64_encode(MyProcPort->scram_ServerKey, sizeof(MyProcPort->scram_ServerKey), (char *) values[n], len); if (encoded_len < 0) |
