Re: [PATCH] libfdisk: fix gpt for 32bit systems

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

 



On Wednesday 05 April 2017, Karel Zak wrote:
> On Wed, Apr 05, 2017 at 11:56:29AM +0200, Ruediger Meier wrote:
> > From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
> >
> > test libfdisk/gpt failed since bb676203 because UINT32_MAX does
> > not fit into ssize_t on 32bit systems.
> >
> > This patch rewrites parts of commit f71b96bf. Also handling
> > multiplication overflow and some typos. Note that it still looks
> > questionable that we would try to read() SSIZE_MAX bytes in
> > gpt_read_entries().
>
> Maybe it would be better to have
>
>   #define FDISK_GPT_NENTRIES_MAX  (SIZE_MAX/sizeof(struct gpt_entry))

Yes, I was not sure whether f71b96bf really cares for UINT32_MAX or if 
SIZE_MAX... would be good enough as the only limit.

> to avoid all the checks. We have to be able to store the entries
> array to the memory, so all should be based on this fact. Things like
>
>     uint64_t sz;
>     ...
>     ret = calloc(1, sz);
>
> are just crazy fun...
>
> It also seems that the code does not care if
> header->sizeof_partition_entry is the same as sizeof(struct
> gpt_entry), but we use the array as "struct gpt_entry".
>
> The really correct way is to use
>
>     (char *)buf + i * header->sizeof_partition_entry
>
> to get the entry.
>
> I'll play with it and send a patch for review.
>
>     Karel


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