From: Rich Salz Date: Fri, 29 Jan 2016 17:09:05 +0000 (-0500) Subject: GH102: Add volatile to CRYPTO_memcmp X-Git-Tag: OpenSSL_1_1_0-pre3~353 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=98ab57644f44d2d83595c2d0f69138a284d6096b;p=oweals%2Fopenssl.git GH102: Add volatile to CRYPTO_memcmp Can't hurt and seems to prevent problems from some over-aggressive (LTO?) compilers. Reviewed-by: Richard Levitte --- diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 14a84243c6..9473799a48 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -465,11 +465,11 @@ void OpenSSLDie(const char *file, int line, const char *assertion) #endif } -int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) +int CRYPTO_memcmp(const volatile void *in_a, const volatile void *in_b, size_t len) { size_t i; - const unsigned char *a = in_a; - const unsigned char *b = in_b; + const volatile unsigned char *a = in_a; + const volatile unsigned char *b = in_b; unsigned char x = 0; for (i = 0; i < len; i++) diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index 26f6c79c8e..024f2c9b72 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -542,7 +542,7 @@ int OPENSSL_gmtime_diff(int *pday, int *psec, * into a defined order as the return value when a != b is undefined, other * than to be non-zero. */ -int CRYPTO_memcmp(const void *a, const void *b, size_t len); +int CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len); /* BEGIN ERROR CODES */ /*