diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-05-08 22:01:25 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-05-08 22:01:25 +0300 |
commit | b28c59a6cd089902e66a91e0d0974da34d1c922b (patch) | |
tree | b114ea0f8fa89e2251b80ef7ba13a04ef0a25891 /src/backend/libpq/crypt.c | |
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 'src/backend/libpq/crypt.c')
-rw-r--r-- | src/backend/libpq/crypt.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index cbb85a27cc1..f6b641e726e 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -136,7 +136,7 @@ encrypt_password(PasswordType target_type, const char *role, case PASSWORD_TYPE_MD5: encrypted_password = palloc(MD5_PASSWD_LEN + 1); - if (!pg_md5_encrypt(password, role, strlen(role), + if (!pg_md5_encrypt(password, (uint8 *) role, strlen(role), encrypted_password, &errstr)) elog(ERROR, "password encryption failed: %s", errstr); break; @@ -201,7 +201,7 @@ encrypt_password(PasswordType target_type, const char *role, int md5_crypt_verify(const char *role, const char *shadow_pass, const char *client_pass, - const char *md5_salt, int md5_salt_len, + const uint8 *md5_salt, int md5_salt_len, const char **logdetail) { int retval; @@ -284,7 +284,7 @@ plain_crypt_verify(const char *role, const char *shadow_pass, case PASSWORD_TYPE_MD5: if (!pg_md5_encrypt(client_pass, - role, + (uint8 *) role, strlen(role), crypt_client_pass, &errstr)) |