Commit 2f6db512fb83f2d8e84e8097ebd2595c6ec8f8eb

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

gf_w64.c: fix integer overflow

Fix for Coverity issue (from Ceph):

CID 1193089 (#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).

CID 1193090 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression 1 << g_s 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 2 additions and 2 deletions   Show diff stats
src/gf_w64.c
... ... @@ -840,8 +840,8 @@ void gf_w64_group_multiply_region(gf_t *gf, void *src, void *dest, gf_val_64_t v
840 840 d64 = (uint64_t *) rd.d_start;
841 841 dtop = (uint64_t *) rd.d_top;
842 842  
843   - smask = (1 << g_s) - 1;
844   - rmask = (1 << g_r) - 1;
  843 + smask = ((uint64_t)1 << g_s) - 1;
  844 + rmask = ((uint64_t)1 << g_r) - 1;
845 845  
846 846 while (d64 < dtop) {
847 847 a64 = *s64;
... ...