Re: [PATCH 2/3] fdisk: avoid segfault validating a sgi label (boot/swap not set)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux