"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: gotd.conf: adds time suffixes to timeouts
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Tue, 3 Jan 2023 16:29:46 +0100

Download raw body.

Thread
On Tue, Jan 03, 2023 at 04:11:56PM +0100, Omar Polo wrote:
> On 2023/01/03 15:17:29 +0100, Stefan Sperling <stsp@stsp.name> wrote:
> > On Tue, Jan 03, 2023 at 10:48:01AM +0100, Omar Polo wrote:
> > > I had something like this lying around in a private parse.y, would it
> > > be useful for gotd too?  It just allows for a slightly more nice
> > > timeout definition, which is quite niche.
> > 
> > I like this. ok
> 
> when adding the check for the multiplication overflow (which my
> private parse.y didn't have) I ended up duplicating some logic from
> strtonum.  no need to check if it's lesser than a value afterwards,
> strtonum does that for us already.

Yes, makes sense. ok.

> diff /home/op/w/got2
> commit - 92c8ec640028151d1e92eaef79c4fcd1365998bc
> path + /home/op/w/got2
> blob - a157b990e93fe1cb15f7ba00f0d218349adca5a2
> file + gotd/parse.y
> --- gotd/parse.y
> +++ gotd/parse.y
> @@ -181,7 +181,7 @@ timeout		: NUMBER {
>  			}
>  
>  			$$.tv_usec = 0;
> -			$$.tv_sec = strtonum($1, 0, INT_MAX, &errstr);
> +			$$.tv_sec = strtonum($1, 0, INT_MAX / mul, &errstr);
>  			if (errstr) {
>  				yyerror("number of %s is %s: %s", type,
>  				    errstr, $1);
> @@ -189,13 +189,6 @@ timeout		: NUMBER {
>  				YYERROR;
>  			}
>  
> -			if ($$.tv_sec > INT_MAX / mul) {
> -				yyerror("number of %s is too too large: %s",
> -				    type, $1);
> -				free($1);
> -				YYERROR;
> -			}
> -
>  			$$.tv_sec *= mul;
>  			free($1);
>  		}
>