Re: [PATCH v2 2/5] parse-options: introduce precision handling for `OPTION_INTEGER`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 16, 2025, 10:28 UTC
- Message-ID
- <Z_-GNqY9gZM6fEsg@pks.im>
- In-Reply-To
- <8e566ea1-5ff4-4854-a1dc-38626510c080@gmail.com>
On Tue, Apr 15, 2025 at 04:51:59PM +0100, Phillip Wood wrote:
Show 19 quoted lines
> On 15/04/2025 13:14, Patrick Steinhardt wrote:
> > Note that we do not yet assert signedness of the passed variable, which
> > is another source of bugs. This will be handled in a subsequent commit.
> >
> > + } else {
> > + value = strtoimax(arg, (char **)&s, 10);
> > + if (*s)
> > + return error(_("%s expects a numerical value"),
> > + optname(opt, flags));
>
> To catch overflow errors for arguments of intimax_t we need to do
>
> errno = 0
> value = strtoimax(arg, (Char **)&s, 10);
> if (errno || *s)
> return error(...)
>
> to catch the error when we parse the string as the checks below only work
> for narrower types.Fair. This issue isn't new -- it already existed before my patch series. But that's not a good enough reason to not fix it while we're at it.
Patrick