From: Pauli Date: Wed, 16 Mar 2022 03:13:25 +0000 (+1100) Subject: Fix Coverity 1498612: integer overflow X-Git-Tag: openssl-3.2.0-alpha1~2816 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81487b65b9eb8148471e729b8c1959521d62c69e;p=thirdparty%2Fopenssl.git Fix Coverity 1498612: integer overflow The assert added cannot ever fail because (current & 0xFFFF) != 0 from the while loop and the trailing zero bit count therefore cannot be as large as 32. Reviewed-by: Tomas Mraz Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/17892) --- diff --git a/crypto/ec/curve448/curve448.c b/crypto/ec/curve448/curve448.c index 9b9786da8fe..4db72cd28d9 100644 --- a/crypto/ec/curve448/curve448.c +++ b/crypto/ec/curve448/curve448.c @@ -586,6 +586,7 @@ static int recode_wnaf(struct smvt_control *control, int32_t delta = odd & mask; assert(position >= 0); + assert(pos < 32); /* can't fail since current & 0xFFFF != 0 */ if (odd & (1 << (table_bits + 1))) delta -= (1 << (table_bits + 1)); current -= delta * (1 << pos);