Skip to content

Commit 2676040

Browse files
committed
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 b67b57a, 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
1 parent 5388216 commit 2676040

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/common/md5.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ static const uint8 md5_paddat[MD5_BUFLEN] = {
150150
0, 0, 0, 0, 0, 0, 0, 0,
151151
};
152152

153-
#ifdef WORDS_BIGENDIAN
154-
static uint32 X[16];
155-
#endif
156-
157153
static void
158154
md5_calc(const uint8 *b64, pg_md5_ctx *ctx)
159155
{
@@ -167,6 +163,7 @@ md5_calc(const uint8 *b64, pg_md5_ctx *ctx)
167163
#else
168164
/* 4 byte words */
169165
/* what a brute force but fast! */
166+
uint32 X[16];
170167
uint8 *y = (uint8 *) X;
171168

172169
y[0] = b64[3];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy