diff mbox

[7/7] kpartx: fix dos partition rollover error

Message ID 1464736610-20027-8-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Benjamin Marzinski May 31, 2016, 11:16 p.m. UTC
dos partitions are limited to 2^32 sectors. However these do not have to
be 512 byte sectors, which is what device-mapper tables use.  kpartx
stores the dos sectors in a 32 uint.  This means that on a 4k sector size
device with large enough partitions, when kpartx multiplies the
dos sector count by the sector size multiplier, it can rollover before
it gets stored in 64 bit slice sector count. This patch just changes the
multiplier to a 64 bit uint to match the slice sector count, and avoid
the rollover.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 kpartx/dos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/kpartx/dos.c b/kpartx/dos.c
index 90ad3bd..f252d0a 100644
--- a/kpartx/dos.c
+++ b/kpartx/dos.c
@@ -79,7 +79,7 @@  read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) {
 	unsigned long offset = all.start;
 	int i, n=4;
 	unsigned char *bp;
-	int sector_size_mul = get_sector_size(fd)/512;
+	uint64_t  sector_size_mul = get_sector_size(fd)/512;
 
 	bp = (unsigned char *)getblock(fd, offset);
 	if (bp == NULL)