dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
Blob Blame History Raw
From 44baaedaffee029dca76796b933412d97a19dff6 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 9 Sep 2013 10:57:50 +0200
Subject: [PATCH] libfdisk: fix SIGFPE

 #0 recount_geometry at libfdisk/src/alignment.c:143
 #1 fdisk_discover_geometry at libfdisk/src/alignment.c:205
 #2 fdisk_context_assign_device at libfdisk/src/context.c:173
 #3 print_partition_table_from_option at fdisks/fdisk.c:924

References: https://bugzilla.redhat.com/show_bug.cgi?id=1005566
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 libfdisk/src/alignment.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c
index ac44e73..4d4ab48 100644
--- a/libfdisk/src/alignment.c
+++ b/libfdisk/src/alignment.c
@@ -193,11 +193,12 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
 
 	/* what the kernel/bios thinks the geometry is */
 	blkdev_get_geometry(cxt->dev_fd, &h, &s);
-	if (!h && !s) {
-		/* unable to discover geometry, use default values */
-		s = 63;
+
+	/* defaults */
+	if (!h)
 		h = 255;
-	}
+	if (!s)
+		s = 63;
 
 	/* obtained heads and sectors */
 	cxt->geom.heads = h;
-- 
1.8.1.4