]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bitmap: avoid 32bit integer overflow in shift 611/head
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 17 Jul 2015 10:19:06 +0000 (12:19 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Fri, 17 Jul 2015 10:19:06 +0000 (12:19 +0200)
We really must use 64bit integers to calculate long-long shifts.
Otherwise, we will never get higher masks than 2^31.

src/basic/bitmap.c

index 83448ca93c6ba74278c1f524e4b4ff33947e4d68..c5039fd22f2623e8ae49eaac13c27c0dd9a8915d 100644 (file)
@@ -157,7 +157,7 @@ bool bitmap_iterate(Bitmap *b, Iterator *i, unsigned *n) {
 
         offset = BITMAP_NUM_TO_OFFSET(i->idx);
         rem = BITMAP_NUM_TO_REM(i->idx);
-        bitmask = 1 << rem;
+        bitmask = 1ULL << rem;
 
         for (; offset < b->n_bitmaps; offset ++) {
                 if (b->bitmaps[offset]) {