Selaa lähdekoodia

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 <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/17892)
Pauli 2 vuotta sitten
vanhempi
commit
81487b65b9
1 muutettua tiedostoa jossa 1 lisäystä ja 0 poistoa
  1. 1 0
      crypto/ec/curve448/curve448.c

+ 1 - 0
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);