bug-parted
[Top][All Lists]
Advanced

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

bug#34392: [PATCH] Avoid sigsegv in case 2nd nilfs2 superblock magic acc


From: Brian C. Lane
Subject: bug#34392: [PATCH] Avoid sigsegv in case 2nd nilfs2 superblock magic accidently found.
Date: Mon, 11 Feb 2019 11:59:31 -0800
User-agent: Mutt/1.10.1 (2018-07-13)

On Fri, Feb 08, 2019 at 11:03:55PM +0000, Mike Small wrote:
> Hi,
> 
> Someone shared with me a case where parted 3.2 (3.2-15 as packaged in
> Ubuntu Xenial) hit a sigsegv when run as follows:

Good job tracking this down! Yes, a test would be good to have, I think
this is one of those corner cases that can bite people and lead to lots
of confusion :)

>       crc = __efi_crc32(sb, sumoff, PED_LE32_TO_CPU(sb->s_crc_seed));
> @@ -113,11 +113,13 @@ nilfs2_probe (PedGeometry* geom)
>       const int sectors = (4096 + geom->dev->sector_size - 1) /
>                            geom->dev->sector_size;
>       char *buf = alloca (sectors * geom->dev->sector_size);
> -     void *buff2 = alloca (geom->dev->sector_size);
> +     const int sectors2 = sizeof(struct nilfs2_super_block) / 
> geom->dev->sector_size +
> +                (sizeof(struct nilfs2_super_block) % geom->dev->sector_size 
> == 0) ? 0 : 1;

This calculation is correct, but I find it hard to read. If you use the
same technique as it does for sectors it would be easier to understand
in the future, and I don't think the superblock size is going to change.

-- 
Brian C. Lane (PST8PDT)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]