FYI,

Thanks again Martin.
I'm about to commit this in your name, now that I finally
reproduced the problem.

>From 31d0a1a21631a716736fc6998c0f730230ec1b99 Mon Sep 17 00:00:00 2001
From: Martin Poole <mpo...@redhat.com>
Date: Wed, 5 May 2010 18:24:22 +0200
Subject: [PATCH] ext2: don't overflow when creating a partition of size 2TiB or 
larger

Without this patch, mkpartfs would succeed in creating an ext2
partition, but the resulting partition would fail a mkfs.ext2 -f check.
* libparted/fs/ext2/parted_io.c (do_read): Avoid overflow 32-bit
sector count overflow for a partition of size 2TiB or larger.
(do_write): Likewise.
See http://bugzilla.redhat.com/584057#c16 a reproducer.
---
 libparted/fs/ext2/parted_io.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libparted/fs/ext2/parted_io.c b/libparted/fs/ext2/parted_io.c
index 522ea98..f6154d6 100644
--- a/libparted/fs/ext2/parted_io.c
+++ b/libparted/fs/ext2/parted_io.c
@@ -82,7 +82,9 @@ static int do_read(void *cookie, void *ptr, blk_t block, 
blk_t num)
 {
        struct my_cookie *monster = cookie;

-       return ped_geometry_read(monster->geom, ptr, block << (monster->logsize 
- 9), num << (monster->logsize - 9));
+       return ped_geometry_read(monster->geom, ptr,
+                                (PedSector) block << (monster->logsize - 9),
+                                (PedSector) num << (monster->logsize - 9));
 }

 static int do_set_blocksize(void *cookie, int logsize)
@@ -98,8 +100,8 @@ static int do_write(void *cookie, void *ptr, blk_t block, 
blk_t num)
        struct my_cookie *monster = cookie;

        return ped_geometry_write(monster->geom, ptr,
-                                 block << (monster->logsize - 9),
-                                 num << (monster->logsize - 9));
+                                 (PedSector) block << (monster->logsize - 9),
+                                 (PedSector) num << (monster->logsize - 9));
 }


--
1.7.1.335.g6845a


_______________________________________________
bug-parted mailing list
bug-parted@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-parted

Reply via email to