commit 71cd355cb2711ad528715bbbb5b41be7c26ace2a from: Omar Polo date: Tue Jan 03 15:31:35 2023 UTC simplify gotd' timeouts string parsing no need to duplicate what strtonum does; pass the *real* maximum value allowed to it directly. ok stsp@ commit - 345b67f25dce7f6a5c981475844df01418a75cbb commit + 71cd355cb2711ad528715bbbb5b41be7c26ace2a blob - a157b990e93fe1cb15f7ba00f0d218349adca5a2 blob + d8319e4be5f8185780729a14a4a706eb136762d2 --- 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); }