aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-auth-scram.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2025-05-08 22:01:25 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2025-05-08 22:01:25 +0300
commitb28c59a6cd089902e66a91e0d0974da34d1c922b (patch)
treeb114ea0f8fa89e2251b80ef7ba13a04ef0a25891 /src/interfaces/libpq/fe-auth-scram.c
parent965213d9c56a671086525a65f5427653b4a66350 (diff)
downloadpostgresql-b28c59a6cd089902e66a91e0d0974da34d1c922b.tar.gz
postgresql-b28c59a6cd089902e66a91e0d0974da34d1c922b.zip
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 'src/interfaces/libpq/fe-auth-scram.c')
-rw-r--r--src/interfaces/libpq/fe-auth-scram.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/interfaces/libpq/fe-auth-scram.c b/src/interfaces/libpq/fe-auth-scram.c
index fe18615197f..f6d6a5aa977 100644
--- a/src/interfaces/libpq/fe-auth-scram.c
+++ b/src/interfaces/libpq/fe-auth-scram.c
@@ -70,14 +70,14 @@ typedef struct
/* These come from the server-first message */
char *server_first_message;
- char *salt;
+ uint8 *salt;
int saltlen;
int iterations;
char *nonce;
/* These come from the server-final message */
char *server_final_message;
- char ServerSignature[SCRAM_MAX_KEY_LEN];
+ uint8 ServerSignature[SCRAM_MAX_KEY_LEN];
} fe_scram_state;
static bool read_server_first_message(fe_scram_state *state, char *input);
@@ -350,7 +350,7 @@ static char *
build_client_first_message(fe_scram_state *state)
{
PGconn *conn = state->conn;
- char raw_nonce[SCRAM_RAW_NONCE_LEN + 1];
+ uint8 raw_nonce[SCRAM_RAW_NONCE_LEN + 1];
char *result;
int channel_info_len;
int encoded_len;
@@ -513,7 +513,7 @@ build_client_final_message(fe_scram_state *state)
free(cbind_input);
goto oom_error;
}
- encoded_cbind_len = pg_b64_encode(cbind_input, cbind_input_len,
+ encoded_cbind_len = pg_b64_encode((uint8 *) cbind_input, cbind_input_len,
buf.data + buf.len,
encoded_cbind_len);
if (encoded_cbind_len < 0)
@@ -574,7 +574,7 @@ build_client_final_message(fe_scram_state *state)
encoded_len = pg_b64_enc_len(state->key_length);
if (!enlargePQExpBuffer(&buf, encoded_len))
goto oom_error;
- encoded_len = pg_b64_encode((char *) client_proof,
+ encoded_len = pg_b64_encode(client_proof,
state->key_length,
buf.data + buf.len,
encoded_len);
@@ -694,7 +694,7 @@ read_server_final_message(fe_scram_state *state, char *input)
{
PGconn *conn = state->conn;
char *encoded_server_signature;
- char *decoded_server_signature;
+ uint8 *decoded_server_signature;
int server_signature_len;
state->server_final_message = strdup(input);
@@ -916,7 +916,7 @@ pg_fe_scram_build_secret(const char *password, int iterations, const char **errs
{
char *prep_password;
pg_saslprep_rc rc;
- char saltbuf[SCRAM_DEFAULT_SALT_LEN];
+ uint8 saltbuf[SCRAM_DEFAULT_SALT_LEN];
char *result;
/*