From: Andreas Schneider Date: Thu, 22 Nov 2018 14:06:42 +0000 (+0100) Subject: lib:util: Fix undefined behavior in bitmap.c X-Git-Tag: tdb-1.3.17~665 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93ab0cef2a0f68788f77d8fce7e4f795e9921a9b;p=thirdparty%2Fsamba.git lib:util: Fix undefined behavior in bitmap.c lib/util/bitmap.c:77: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Signed-off-by: Andreas Schneider Reviewed-by: Gary Lockyer --- diff --git a/lib/util/bitmap.c b/lib/util/bitmap.c index 63963356f98..12cdfe4d16a 100644 --- a/lib/util/bitmap.c +++ b/lib/util/bitmap.c @@ -74,7 +74,7 @@ bool bitmap_set(struct bitmap *bm, unsigned i) i, bm->n)); return false; } - bm->b[i/32] |= (1<<(i%32)); + bm->b[i/32] |= (1U<<(i%32)); return true; } @@ -88,7 +88,7 @@ bool bitmap_clear(struct bitmap *bm, unsigned i) i, bm->n)); return false; } - bm->b[i/32] &= ~(1<<(i%32)); + bm->b[i/32] &= ~(1U<<(i%32)); return true; } @@ -98,7 +98,7 @@ query a bit in a bitmap bool bitmap_query(struct bitmap *bm, unsigned i) { if (i >= bm->n) return false; - if (bm->b[i/32] & (1<<(i%32))) { + if (bm->b[i/32] & (1U<<(i%32))) { return true; } return false;