util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Francesco Cosoleto <cosoleto@gmail.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 2/3] fdisk: avoid segfault validating a sgi label (boot/swap not set)
Date: Mon, 14 Nov 2011 15:23:15 +0100	[thread overview]
Message-ID: <20111114142315.GC23020@nb.net.home> (raw)
In-Reply-To: <1321278439-9392-2-git-send-email-cosoleto@gmail.com>

On Mon, Nov 14, 2011 at 02:47:18PM +0100, Francesco Cosoleto wrote:
> swap_part or boot_part can be set to -1 when they don't exist.

 Applied, thanks... but, how do you know that the number could be
 smaller than zero? Do you have any example/code?

>  int
>  sgi_get_swappartition(void)
>  {
> -	return SSWAP16(sgilabel->swap_part);
> +	return (short) SSWAP16(sgilabel->swap_part);
>  }

 It would be nice to cleanup whole fdisksgilabel.c and use
 be32_to_cpu() and be16_to_cpu() there. (See include/bitops.h).

 [...]

>  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 */

 I prefer stdint.h types (e.g. int16_t) for things like on-disk
 labels/superblocks. But it's nothing urgent... whole fdisk should be
 refactored one day ;-)
 
 See for example libblkid/src/partitions/sgi.c. (Well, my long-term
 goal is to use libblkid for partition tables parsing in fdisk.)

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2011-11-14 14:23 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 ` [PATCH 2/3] fdisk: avoid segfault validating a sgi label (boot/swap not set) Francesco Cosoleto
2011-11-14 14:23   ` Karel Zak [this message]
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=20111114142315.GC23020@nb.net.home \
    --to=kzak@redhat.com \
    --cc=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).