]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Cast to long long before left-shifting too much.
authorNeilBrown <neilb@suse.de>
Thu, 22 Jul 2010 05:28:15 +0000 (15:28 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 22 Jul 2010 05:35:54 +0000 (15:35 +1000)
When left-shifting we must be sure that the value being
shifted is large enough to not lose bits.
The 'chunkssize' in CreateBitmap is only 'long' so it
can overflow.  So cast to 'long long' first.

Also fix a similar issue in Detail even though it isn't currently
being compiled.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Tomasz Chmielewski <mangoo@wpkg.org>
Detail.c
bitmap.c

index 3d6b10fdb6a98e932e2636197d434ac004c73382..5116ccac7e9bed70d1a6d096c974159ec1869eb2 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -409,7 +409,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
 #if 0
 This is pretty boring
                        printf("  Reshape pos'n : %llu%s\n", (unsigned long long) info.reshape_progress<<9,
-                              human_size(info.reshape_progress<<9));
+                              human_size((unsigned long long)info.reshape_progress<<9));
 #endif
                        if (info.delta_disks > 0)
                                printf("  Delta Devices : %d, (%d->%d)\n",
index beef2dcdbb3d558ad5c81da1d16ce6b6774006ca..44a86773ddfef02a8530c60b60532a3e87f42f05 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -373,7 +373,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],
                 */
                chunksize = DEFAULT_BITMAP_CHUNK;
                /* <<20 for 2^20 chunks, >>9 to convert bytes to sectors */
-               while (array_size > (chunksize << (20-9)))
+               while (array_size > ((unsigned long long)chunksize << (20-9)))
                        chunksize <<= 1;
        }