]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix Coverity 1498612 & 1503221: integer overflow
authorPauli <pauli@openssl.org>
Thu, 31 Mar 2022 22:33:17 +0000 (09:33 +1100)
committerPauli <ppzgs1@gmail.com>
Sun, 3 Apr 2022 02:53:13 +0000 (12:53 +1000)
Both are the same issue and both as false positives.  Annotate the line so
that this is ignored.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/18012)

crypto/ec/curve448/curve448.c

index 4db72cd28d9c5d3edac2e34d210da5a533f784f4..2fbeb45612b567dab00487370f2491b7cfe226b9 100644 (file)
@@ -586,9 +586,15 @@ 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));
+            /*
+             * Coverity gets confused by the value of pos, thinking it might be
+             * 32.  This would require current & 0xFFFF to be zero which isn't
+             * possible.  Suppress this false positive, since adding a check
+             * isn't desirable.
+             */
+            /* coverity[overflow_before_widen] */
             current -= delta * (1 << pos);
             control[position].power = pos + 16 * (w - 1);
             control[position].addend = delta;