]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix GCC compilation -Waggressive-loop-optimizations
authorAdrien Zinger <zinger.ad@gmail.com>
Wed, 20 Mar 2024 08:39:16 +0000 (09:39 +0100)
committerNeil Horman <nhorman@openssl.org>
Tue, 2 Apr 2024 17:21:59 +0000 (13:21 -0400)
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 <tomas@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23898)

crypto/bn/rsaz_exp_x2.c

index 70705486a154fba2d572975641360fad13500c7e..e9a8e3cbbd2284614658f9ab6f1e03681c62510f 100644 (file)
@@ -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)