Thread-unsafe MD5 on big-endian systems with no OpenSSL

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Thread-unsafe MD5 on big-endian systems with no OpenSSL
Date: 2024-08-06 12:23:26
Message-ID: dfa2015d-ad21-4802-a4cc-3850fc5fff3f@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While browsing through all our global variables for the multithreading
effort, I noticed that our MD5 implementation in src/common/md5.c uses a
static buffer on big-endian systems, which makes it not thread-safe.
That's a bug because that function is also used in libpq.

This was introduced in commit b67b57a966, which replaced the old MD5
fallback implementation with the one from pgcrypto. The thread-safety
didn't matter for pgcrypto, but for libpq it does.

This only affects big-endian systems that are compiled without OpenSSL.

--
Heikki Linnakangas
Neon (https://neon.tech)

Attachment Content-Type Size
0001-Make-fallback-MD5-implementation-thread-safe-on-big-.patch text/x-patch 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2024-08-06 12:37:04 Re: pg_combinebackup does not detect missing files
Previous Message Dean Rasheed 2024-08-06 11:52:32 Re: Optimize mul_var() for var1ndigits >= 8