mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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/dfa2015d-ad21-4802-a4cc-3850fc5fff3f@iki.fi
This commit is contained in:
parent
3cc5e51ab4
commit
a38f5f880d
@ -150,10 +150,6 @@ static const uint8 md5_paddat[MD5_BUFLEN] = {
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
|
||||||
static uint32 X[16];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
md5_calc(const uint8 *b64, pg_md5_ctx *ctx)
|
md5_calc(const uint8 *b64, pg_md5_ctx *ctx)
|
||||||
{
|
{
|
||||||
@ -167,6 +163,7 @@ md5_calc(const uint8 *b64, pg_md5_ctx *ctx)
|
|||||||
#else
|
#else
|
||||||
/* 4 byte words */
|
/* 4 byte words */
|
||||||
/* what a brute force but fast! */
|
/* what a brute force but fast! */
|
||||||
|
uint32 X[16];
|
||||||
uint8 *y = (uint8 *) X;
|
uint8 *y = (uint8 *) X;
|
||||||
|
|
||||||
y[0] = b64[3];
|
y[0] = b64[3];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user