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>
master
Danny Al-Gaaf 2015-06-18 08:58:20 +02:00
parent 98e5e37159
commit e127bb1fb9
1 changed files with 1 additions and 1 deletions

View File

@ -791,7 +791,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
lshift = ((lshift-1) / g_r) * g_r;
rshift = 64 - lshift;
mask = (1 << g_r) - 1;
mask = ((uint64_t)1 << g_r) - 1;
while (lshift >= 0) {
tp = gd->reduce[(top >> lshift) & mask];
top ^= (tp >> rshift);