Source: parted
Version: 3.2
Severity: normal
Tags: patch upstream

Dear Maintainer,

Running parted <logical volume name> print against a logical volume
residing on a DASD will result in a core dump, caused by divide by zero.
See also https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1541510
and
http://lists.alioth.debian.org/pipermail/parted-devel/2016-February/004790.html.
The attached patch provides a solution for the problem.

Thanks!

>From c351c57bb440d7b56830832a255b62d89804ea3d Mon Sep 17 00:00:00 2001
From: Viktor Mihajlovski <[email protected]>
Date: Thu, 4 Feb 2016 16:47:21 +0100
Subject: [PATCH] fdasd.c: Safeguard against geometry misprobing

Fixes an issue with parted print being run against a logical
volume realised by extents on a physical volume residing on
a DASD.
We must make sure that geometry, device blocksize and DASD
attributes are present before we start format verifications
If any of it is missing this is not a DASD.

Signed-off-by: Viktor Mihajlovski <[email protected]>
---
 libparted/labels/fdasd.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 7e6a77a..968b332 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -1021,13 +1021,20 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
 			goto error;
 		}
 
-		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
+		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0 ||
+		        anc->geo.heads == 0 ||
+		        anc->geo.sectors == 0 ||
+		        anc->geo.cylinders == 0 ) {
 			fdasd_error(anc, unable_to_ioctl,
 			    _("Could not retrieve disk geometry information."));
+			goto error;
+		}
 
-		if (ioctl(f, BLKSSZGET, &blksize) != 0)
+		if (ioctl(f, BLKSSZGET, &blksize) != 0) {
 			fdasd_error(anc, unable_to_ioctl,
 			    _("Could not retrieve blocksize information."));
+			goto error;
+		}
 
 		/* get disk type */
 		if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {
-- 
1.9.1

Reply via email to