summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHeikki Linnakangas2024-08-07 07:43:52 +0000
committerHeikki Linnakangas2024-08-07 07:43:52 +0000
commit2676040df0b2ebbcf8af759dbe5d34f393c3d5b5 (patch)
tree7b38c2c72695bfde7b3c5264bbc89e5b8827a8d3 /src/common
parent5388216f6adc7eac20f32db33cc5ce54ef0cc930 (diff)
Make fallback MD5 implementation thread-safe on big-endian systems
Replace a static scratch buffer with a local variable, because a static buffer makes the function not thread-safe. This function is used in client-code in libpq, so it needs to be thread-safe. It was until commit b67b57a966, which replaced the implementation with the one from pgcrypto. Backpatch to v14, where we switched to the new implementation. Reviewed-by: Robert Haas, Michael Paquier Discussion: https://www.postgresql.org/message-id/[email protected]
Diffstat (limited to 'src/common')
-rw-r--r--src/common/md5.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/common/md5.c b/src/common/md5.c
index f1d47722f8a..32b696a66df 100644
--- a/src/common/md5.c
+++ b/src/common/md5.c
@@ -150,10 +150,6 @@ static const uint8 md5_paddat[MD5_BUFLEN] = {
0, 0, 0, 0, 0, 0, 0, 0,
};
-#ifdef WORDS_BIGENDIAN
-static uint32 X[16];
-#endif
-
static void
md5_calc(const uint8 *b64, pg_md5_ctx *ctx)
{
@@ -167,6 +163,7 @@ md5_calc(const uint8 *b64, pg_md5_ctx *ctx)
#else
/* 4 byte words */
/* what a brute force but fast! */
+ uint32 X[16];
uint8 *y = (uint8 *) X;
y[0] = b64[3];