NeilBrown: Cast to long long before left-shifting too much.

Martin F. Krafft madduck at alioth.debian.org
Sun Aug 29 11:54:34 UTC 2010


Module: mdadm
Branch: debian/conffile-location
Commit: 3e4165619b146d3134838c6546778c02308c462e
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=3e4165619b146d3134838c6546778c02308c462e

Author: NeilBrown <neilb at suse.de>
Date:   Thu Jul 22 15:28:15 2010 +1000

Cast to long long before left-shifting too much.

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 at suse.de>
Reported-by: Tomasz Chmielewski <mangoo at wpkg.org>

---

 Detail.c |    2 +-
 bitmap.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Detail.c b/Detail.c
index 3d6b10f..5116cca 100644
--- 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",
diff --git a/bitmap.c b/bitmap.c
index beef2dc..44a8677 100644
--- 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;
 	}
 




More information about the pkg-mdadm-commits mailing list