Commit e127bb1fb9b1025094a0e0ce50d2e44c38c4e97f

Authored by Danny Al-Gaaf
1 parent 98e5e371
Exists in master and in 1 other branch v3

gf_w64.c: fix integer overflow

Fix for Coverity issue (from Ceph):

CID 1193087 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression 1 << g_r with type
  int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used
  in a context that expects an expression of type uint64_t (64 bits, unsigned).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Showing 1 changed file with 1 additions and 1 deletions   Show diff stats
src/gf_w64.c
... ... @@ -791,7 +791,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
791 791  
792 792 lshift = ((lshift-1) / g_r) * g_r;
793 793 rshift = 64 - lshift;
794   - mask = (1 << g_r) - 1;
  794 + mask = ((uint64_t)1 << g_r) - 1;
795 795 while (lshift >= 0) {
796 796 tp = gd->reduce[(top >> lshift) & mask];
797 797 top ^= (tp >> rshift);
... ...