]> git.ipfire.org Git - thirdparty/util-linux.git/commit
fdisk: sgi: abort on HDIO_GETGEO failure
authorDavidlohr Bueso <dave@gnu.org>
Sun, 6 May 2012 12:10:25 +0000 (14:10 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 10 May 2012 09:40:21 +0000 (11:40 +0200)
commit50f6100a960d96471980a9a5354d9ee426b00673
treedd5bf23e2332c7543db5bc7638283ab26c9d546b
parent8335c780ee5adf34b86893fff9ba9de4dd161602
fdisk: sgi: abort on HDIO_GETGEO failure

When the HDIO_GETGEO ioctl fails on non IRIX/MIPS platforms (ie: inappropriate
ioctl for device) the variables that describe the geometry are compromissed.
One clear example is a division by 0 bug because the cylinder size is 0 is
verify_sgi():

$> fdisk sgi.img
Welcome to fdisk (util-linux 2.21.392-4b1c).

...

Command (m for help): x

Expert command (m for help): g
Building a new SGI disklabel.
Partition 11 of type SGI volume and of size 7.9 MiB is set
Floating point exception

Fix this by simply exiting the program instead of leaving it in a vulnerable
state.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/fdisksgilabel.c