Subject: Re: [PATCH v2 2/5] parse-options: introduce precision handling for `OPTION_INTEGER`

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 16 Apr 2025 12:28:06 +0200

On Tue, Apr 15, 2025 at 04:51:59PM +0100, Phillip Wood wrote:
> 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