]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix possible floating point exception
authorKarel Zak <kzak@redhat.com>
Wed, 25 Sep 2013 09:45:59 +0000 (11:45 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 25 Sep 2013 09:45:59 +0000 (11:45 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/sun.c

index 41c156767a00a3a13dcf9f5cccc093deabaa5cf8..5c38e8cca7c97d7ecba3aaae6164d2b0cd5542e6 100644 (file)
@@ -220,7 +220,10 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
        sec_fac = cxt->sector_size / 512;
 
 #ifdef HDIO_GETGEO
-       if (!ioctl(cxt->dev_fd, HDIO_GETGEO, &geometry)) {
+       if (ioctl(cxt->dev_fd, HDIO_GETGEO, &geometry) == 0
+           && geometry.heads
+           && geometry.sectors) {
+
                cxt->geom.heads = geometry.heads;
                cxt->geom.sectors = geometry.sectors;
                if (res == 0) {