Blame SOURCES/0024-fdasd.c-Safeguard-against-geometry-misprobing.patch

7fd79c
From 953f340c3e24c296e9e73f4a0b45ff6563359592 Mon Sep 17 00:00:00 2001
7fd79c
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
7fd79c
Date: Fri, 5 Feb 2016 14:47:11 +0100
7fd79c
Subject: [PATCH] fdasd.c: Safeguard against geometry misprobing
7fd79c
7fd79c
Fixes an issue with parted print being run against a logical
7fd79c
volume realised by extents on a physical volume residing on
7fd79c
a DASD.
7fd79c
We must make sure that geometry, device blocksize and DASD
7fd79c
attributes are present before we start format verifications
7fd79c
If any of it is missing this is not a DASD.
7fd79c
7fd79c
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
7fd79c
Signed-off-by: Brian C. Lane <bcl@redhat.com>
7fd79c
---
7fd79c
 libparted/labels/fdasd.c | 11 +++++++++--
7fd79c
 1 file changed, 9 insertions(+), 2 deletions(-)
7fd79c
7fd79c
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
7fd79c
index 7e6a77a..968b332 100644
7fd79c
--- a/libparted/labels/fdasd.c
7fd79c
+++ b/libparted/labels/fdasd.c
7fd79c
@@ -1021,13 +1021,20 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
7fd79c
 			goto error;
7fd79c
 		}
7fd79c
 
7fd79c
-		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
7fd79c
+		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0 ||
7fd79c
+		        anc->geo.heads == 0 ||
7fd79c
+		        anc->geo.sectors == 0 ||
7fd79c
+		        anc->geo.cylinders == 0 ) {
7fd79c
 			fdasd_error(anc, unable_to_ioctl,
7fd79c
 			    _("Could not retrieve disk geometry information."));
7fd79c
+			goto error;
7fd79c
+		}
7fd79c
 
7fd79c
-		if (ioctl(f, BLKSSZGET, &blksize) != 0)
7fd79c
+		if (ioctl(f, BLKSSZGET, &blksize) != 0) {
7fd79c
 			fdasd_error(anc, unable_to_ioctl,
7fd79c
 			    _("Could not retrieve blocksize information."));
7fd79c
+			goto error;
7fd79c
+		}
7fd79c
 
7fd79c
 		/* get disk type */
7fd79c
 		if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {
7fd79c
-- 
7fd79c
2.5.0
7fd79c