Skip to content

Commit

Permalink
gf_w64.c: fix integer overflow
Browse files Browse the repository at this point in the history
Fix for Coverity issue (from Ceph):

CID 1193088 (#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>
(cherry picked from commit 1aef869)
  • Loading branch information
dalgaaf authored and ldachary committed Sep 6, 2015
1 parent 513c87b commit 93a9845
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/gf_w64.c
Expand Up @@ -767,7 +767,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
gd = (struct gf_w64_group_data *) h->private;
gf_w64_group_set_shift_tables(gd->shift, b, h);

mask = ((1 << g_s) - 1);
mask = (((uint64_t)1 << g_s) - 1);
top = 0;
bot = gd->shift[a&mask];
a >>= g_s;
Expand Down

0 comments on commit 93a9845

Please sign in to comment.