]>
Commit | Line | Data |
---|---|---|
c886eb9d AM |
1 | From 953f340c3e24c296e9e73f4a0b45ff6563359592 Mon Sep 17 00:00:00 2001 |
2 | From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> | |
3 | Date: Fri, 5 Feb 2016 14:47:11 +0100 | |
4 | Subject: [PATCH] fdasd.c: Safeguard against geometry misprobing | |
5 | ||
6 | Fixes an issue with parted print being run against a logical | |
7 | volume realised by extents on a physical volume residing on | |
8 | a DASD. | |
9 | We must make sure that geometry, device blocksize and DASD | |
10 | attributes are present before we start format verifications | |
11 | If any of it is missing this is not a DASD. | |
12 | ||
13 | Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> | |
14 | Signed-off-by: Brian C. Lane <bcl@redhat.com> | |
15 | --- | |
16 | libparted/labels/fdasd.c | 11 +++++++++-- | |
17 | 1 file changed, 9 insertions(+), 2 deletions(-) | |
18 | ||
19 | diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c | |
20 | index 7e6a77a..968b332 100644 | |
21 | --- a/libparted/labels/fdasd.c | |
22 | +++ b/libparted/labels/fdasd.c | |
23 | @@ -1021,13 +1021,20 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f) | |
24 | goto error; | |
25 | } | |
26 | ||
27 | - if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0) | |
28 | + if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0 || | |
29 | + anc->geo.heads == 0 || | |
30 | + anc->geo.sectors == 0 || | |
31 | + anc->geo.cylinders == 0 ) { | |
32 | fdasd_error(anc, unable_to_ioctl, | |
33 | _("Could not retrieve disk geometry information.")); | |
34 | + goto error; | |
35 | + } | |
36 | ||
37 | - if (ioctl(f, BLKSSZGET, &blksize) != 0) | |
38 | + if (ioctl(f, BLKSSZGET, &blksize) != 0) { | |
39 | fdasd_error(anc, unable_to_ioctl, | |
40 | _("Could not retrieve blocksize information.")); | |
41 | + goto error; | |
42 | + } | |
43 | ||
44 | /* get disk type */ | |
45 | if (ioctl(f, BIODASDINFO, &dasd_info) != 0) { | |
46 | -- | |
47 | 2.5.0 | |
48 |