Commit 1e92f97e1e4942082764213c57c16e61f1f97903

Authored by Danny Al-Gaaf
Committed by Loic Dachary
1 parent 3dfca4f3
Exists in v2

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>
(cherry picked from commit e127bb1fb9b1025094a0e0ce50d2e44c38c4e97f)
Showing 1 changed file with 1 additions and 1 deletions   Show diff stats
@@ -791,7 +791,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b) @@ -791,7 +791,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
791 791
792 lshift = ((lshift-1) / g_r) * g_r; 792 lshift = ((lshift-1) / g_r) * g_r;
793 rshift = 64 - lshift; 793 rshift = 64 - lshift;
794 - mask = (1 << g_r) - 1; 794 + mask = ((uint64_t)1 << g_r) - 1;
795 while (lshift >= 0) { 795 while (lshift >= 0) {
796 tp = gd->reduce[(top >> lshift) & mask]; 796 tp = gd->reduce[(top >> lshift) & mask];
797 top ^= (tp >> rshift); 797 top ^= (tp >> rshift);