From: Francesco Cosoleto <cosoleto@gmail.com>
To: util-linux@vger.kernel.org
Cc: Francesco Cosoleto <cosoleto@gmail.com>
Subject: [PATCH 2/3] fdisk: avoid segfault validating a sgi label (boot/swap not set)
Date: Mon, 14 Nov 2011 14:47:18 +0100 [thread overview]
Message-ID: <1321278439-9392-2-git-send-email-cosoleto@gmail.com> (raw)
In-Reply-To: <1321278439-9392-1-git-send-email-cosoleto@gmail.com>
swap_part or boot_part can be set to -1 when they don't exist.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
---
fdisk/fdisksgilabel.c | 8 ++++----
fdisk/fdisksgilabel.h | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c
index 091902a..002688a 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)
diff --git a/fdisk/fdisksgilabel.h b/fdisk/fdisksgilabel.h
index 1445fa9..1c47bb4 100644
--- a/fdisk/fdisksgilabel.h
+++ b/fdisk/fdisksgilabel.h
@@ -63,8 +63,8 @@ struct device_parameter { /* 48 bytes */
typedef struct {
unsigned int magic; /* expect SGI_LABEL_MAGIC */
- unsigned short boot_part; /* active boot partition */
- unsigned short swap_part; /* active swap partition */
+ short boot_part; /* active boot partition */
+ short swap_part; /* active swap partition */
unsigned char boot_file[16]; /* name of the bootfile */
struct device_parameter devparam; /* 1 * 48 bytes */
struct volume_directory { /* 15 * 16 bytes */
--
1.7.3.4
next prev parent reply other threads:[~2011-11-14 13:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 13:47 [PATCH 1/3] fdisk: use ngettext() in str_units() for plural forms Francesco Cosoleto
2011-11-14 13:47 ` Francesco Cosoleto [this message]
2011-11-14 14:23 ` [PATCH 2/3] fdisk: avoid segfault validating a sgi label (boot/swap not set) Karel Zak
2011-11-14 16:06 ` Francesco Cosoleto
2011-11-14 13:47 ` [PATCH 3/3] fdisk: split delete_partition() off from dos_delete_partition() Francesco Cosoleto
2011-11-14 14:23 ` Karel Zak
2011-11-14 14:08 ` [PATCH 1/3] fdisk: use ngettext() in str_units() for plural forms Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321278439-9392-2-git-send-email-cosoleto@gmail.com \
--to=cosoleto@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).