From: Ruediger Meier <sweet_f_a@gmx.de>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH] libfdisk: fix gpt for 32bit systems
Date: Wed, 5 Apr 2017 13:14:07 +0200 [thread overview]
Message-ID: <201704051314.07435.sweet_f_a@gmx.de> (raw)
In-Reply-To: <20170405105015.pymuuqicbzxmiucj@ws.net.home>
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@ga-group.nl>
> >
> > 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
next prev parent reply other threads:[~2017-04-05 11:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-05 9:56 [PATCH] libfdisk: fix gpt for 32bit systems Ruediger Meier
2017-04-05 10:50 ` Karel Zak
2017-04-05 11:14 ` Ruediger Meier [this message]
2017-04-05 16:50 ` Karel Zak
2017-04-05 17:58 ` Ruediger Meier
2017-04-06 10:28 ` Karel Zak
2017-04-06 10:43 ` Ruediger Meier
2017-04-06 11:32 ` 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=201704051314.07435.sweet_f_a@gmx.de \
--to=sweet_f_a@gmx.de \
--cc=kzak@redhat.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