diff options
author | Francesco Cosoleto | 2011-11-14 14:47:18 +0100 |
---|---|---|
committer | Karel Zak | 2011-11-14 15:07:18 +0100 |
commit | 798d621c3bb5a84592c58fb6176d0d91017e1223 (patch) | |
tree | 962f73ceee4aad3ba175e9d86d5672736bdbd9bf /fdisk/fdisksgilabel.c | |
parent | fdisk: use ngettext() in str_units() for plural forms (diff) | |
download | kernel-qcow2-util-linux-798d621c3bb5a84592c58fb6176d0d91017e1223.tar.gz kernel-qcow2-util-linux-798d621c3bb5a84592c58fb6176d0d91017e1223.tar.xz kernel-qcow2-util-linux-798d621c3bb5a84592c58fb6176d0d91017e1223.zip |
fdisk: avoid segfault validating a sgi label (boot/swap not set)
swap_part or boot_part can be set to -1 when they don't exist.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Diffstat (limited to 'fdisk/fdisksgilabel.c')
-rw-r--r-- | fdisk/fdisksgilabel.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c index 091902ab0..002688a4c 100644 --- a/fdisk/fdisksgilabel.c +++ b/fdisk/fdisksgilabel.c @@ -262,13 +262,13 @@ sgi_get_sysid(int i) int sgi_get_bootpartition(void) { - return SSWAP16(sgilabel->boot_part); + return (short) SSWAP16(sgilabel->boot_part); } int sgi_get_swappartition(void) { - return SSWAP16(sgilabel->swap_part); + return (short) SSWAP16(sgilabel->swap_part); } void @@ -513,10 +513,10 @@ verify_sgi(int verbose) * Go for details now */ if (verbose) { - if (!sgi_get_num_sectors(sgi_get_bootpartition())) { + if (sgi_get_bootpartition() < 0 || !sgi_get_num_sectors(sgi_get_bootpartition())) { printf(_("\nThe boot partition does not exist.\n")); } - if (!sgi_get_num_sectors(sgi_get_swappartition())) { + if (sgi_get_swappartition() < 0 || !sgi_get_num_sectors(sgi_get_swappartition())) { printf(_("\nThe swap partition does not exist.\n")); } else { if ((sgi_get_sysid(sgi_get_swappartition()) != SGI_SWAP) |