]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
threads_win: fix improper cast to long * instead of LONG *
authorGeorgi Valkov <gvalkov@gmail.com>
Tue, 3 Sep 2024 07:13:34 +0000 (10:13 +0300)
committerTomas Mraz <tomas@openssl.org>
Thu, 5 Sep 2024 15:12:19 +0000 (17:12 +0200)
InterlockedExchangeAdd expects arguments of type LONG *, LONG
but the int arguments were improperly cast to long *, long

Note:
- LONG is always 32 bit
- long is 32 bit on Win32 VC x86/x64 and MingW-W64
- long is 64 bit on cygwin64

Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25360)

(cherry picked from commit b0ed90cc30a573acb9b27186babc616be482afcb)

crypto/threads_win.c

index dbeda74d73a70ae91d1d55c569d5a9ef90982c6d..43f36ee6a333badaf5400533b3cab2f3daec6ad3 100644 (file)
@@ -212,7 +212,8 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)
 
 int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
 {
-    *ret = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount;
+    *ret = (int)InterlockedExchangeAdd((LONG volatile *)val, (LONG)amount)
+        + amount;
     return 1;
 }