From: Adrien Zinger Date: Wed, 20 Mar 2024 08:39:16 +0000 (+0100) Subject: Fix GCC compilation -Waggressive-loop-optimizations X-Git-Tag: openssl-3.3.3~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=579a06cea3685e7f739cdd7e8cd3c3efa1c0d7b7;p=thirdparty%2Fopenssl.git Fix GCC compilation -Waggressive-loop-optimizations GCC 13.1.0 were reporting a compilation warning with -O2/3 and -Waggressive-loop-optimizations. GCC is raising an undefined behavior in the while loop. Replace the while loop with a memset call at the top of the function. Fixes #21088 CLA: trivial Reviewed-by: Tomas Mraz Reviewed-by: Bernd Edlinger Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23898) (cherry picked from commit c45ca0656f8d1fe43b8cf444c88d295a063341ca) --- diff --git a/crypto/bn/rsaz_exp_x2.c b/crypto/bn/rsaz_exp_x2.c index 70705486a15..e9a8e3cbbd2 100644 --- a/crypto/bn/rsaz_exp_x2.c +++ b/crypto/bn/rsaz_exp_x2.c @@ -576,11 +576,7 @@ static void to_words52(BN_ULONG *out, int out_len, out_len--; } - while (out_len > 0) { - *out = 0; - out_len--; - out++; - } + memset(out, 0, out_len * sizeof(BN_ULONG)); } static ossl_inline void put_digit(uint8_t *out, int out_len, uint64_t digit)