9d84b2
From 44baaedaffee029dca76796b933412d97a19dff6 Mon Sep 17 00:00:00 2001
9d84b2
From: Karel Zak <kzak@redhat.com>
9d84b2
Date: Mon, 9 Sep 2013 10:57:50 +0200
9d84b2
Subject: [PATCH] libfdisk: fix SIGFPE
9d84b2
9d84b2
 #0 recount_geometry at libfdisk/src/alignment.c:143
9d84b2
 #1 fdisk_discover_geometry at libfdisk/src/alignment.c:205
9d84b2
 #2 fdisk_context_assign_device at libfdisk/src/context.c:173
9d84b2
 #3 print_partition_table_from_option at fdisks/fdisk.c:924
9d84b2
9d84b2
References: https://bugzilla.redhat.com/show_bug.cgi?id=1005566
9d84b2
Signed-off-by: Karel Zak <kzak@redhat.com>
9d84b2
---
9d84b2
 libfdisk/src/alignment.c | 9 +++++----
9d84b2
 1 file changed, 5 insertions(+), 4 deletions(-)
9d84b2
9d84b2
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c
9d84b2
index ac44e73..4d4ab48 100644
9d84b2
--- a/libfdisk/src/alignment.c
9d84b2
+++ b/libfdisk/src/alignment.c
9d84b2
@@ -193,11 +193,12 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
9d84b2
 
9d84b2
 	/* what the kernel/bios thinks the geometry is */
9d84b2
 	blkdev_get_geometry(cxt->dev_fd, &h, &s);
9d84b2
-	if (!h && !s) {
9d84b2
-		/* unable to discover geometry, use default values */
9d84b2
-		s = 63;
9d84b2
+
9d84b2
+	/* defaults */
9d84b2
+	if (!h)
9d84b2
 		h = 255;
9d84b2
-	}
9d84b2
+	if (!s)
9d84b2
+		s = 63;
9d84b2
 
9d84b2
 	/* obtained heads and sectors */
9d84b2
 	cxt->geom.heads = h;
9d84b2
-- 
9d84b2
1.8.1.4
9d84b2