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/include/common | |
parent | 965213d9c56a671086525a65f5427653b4a66350 (diff) | |
download | postgresql-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/include/common')
-rw-r--r-- | src/include/common/base64.h | 4 | ||||
-rw-r--r-- | src/include/common/md5.h | 4 | ||||
-rw-r--r-- | src/include/common/scram-common.h | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/include/common/base64.h b/src/include/common/base64.h index 3f74aa301f0..66cb57b017f 100644 --- a/src/include/common/base64.h +++ b/src/include/common/base64.h @@ -11,8 +11,8 @@ #define BASE64_H /* base 64 */ -pg_nodiscard extern int pg_b64_encode(const char *src, int len, char *dst, int dstlen); -pg_nodiscard extern int pg_b64_decode(const char *src, int len, char *dst, int dstlen); +pg_nodiscard extern int pg_b64_encode(const uint8 *src, int len, char *dst, int dstlen); +pg_nodiscard extern int pg_b64_decode(const char *src, int len, uint8 *dst, int dstlen); extern int pg_b64_enc_len(int srclen); extern int pg_b64_dec_len(int srclen); diff --git a/src/include/common/md5.h b/src/include/common/md5.h index 18ffd998453..0c9ae4888f2 100644 --- a/src/include/common/md5.h +++ b/src/include/common/md5.h @@ -28,9 +28,9 @@ /* Utilities common to all the MD5 implementations, as of md5_common.c */ extern bool pg_md5_hash(const void *buff, size_t len, char *hexsum, const char **errstr); -extern bool pg_md5_binary(const void *buff, size_t len, void *outbuf, +extern bool pg_md5_binary(const void *buff, size_t len, uint8 *outbuf, const char **errstr); -extern bool pg_md5_encrypt(const char *passwd, const char *salt, +extern bool pg_md5_encrypt(const char *passwd, const uint8 *salt, size_t salt_len, char *buf, const char **errstr); diff --git a/src/include/common/scram-common.h b/src/include/common/scram-common.h index 46df94ef1d4..5ce055e0e27 100644 --- a/src/include/common/scram-common.h +++ b/src/include/common/scram-common.h @@ -51,7 +51,7 @@ extern int scram_SaltedPassword(const char *password, pg_cryptohash_type hash_type, int key_length, - const char *salt, int saltlen, int iterations, + const uint8 *salt, int saltlen, int iterations, uint8 *result, const char **errstr); extern int scram_H(const uint8 *input, pg_cryptohash_type hash_type, int key_length, uint8 *result, @@ -64,7 +64,7 @@ extern int scram_ServerKey(const uint8 *salted_password, uint8 *result, const char **errstr); extern char *scram_build_secret(pg_cryptohash_type hash_type, int key_length, - const char *salt, int saltlen, int iterations, + const uint8 *salt, int saltlen, int iterations, const char *password, const char **errstr); #endif /* SCRAM_COMMON_H */ |