On Sat, Mar 16, 2024 at 12:55:07PM +0100, Alejandro Colomar wrote:
> In case INT_MAX==LONG_MAX, we need to check for ERANGE to reject
> high values. The test 'n > INT_MAX' would never be true.
>
> Fixes: d21a9dbc7a83 ("Werner LEMBERG <[email protected]>")
Oops, this should be
("* src/devices/grolbp/lbp.cc: (long_options): Add -w/--linewidth option.")
In v5 I'll send it right. Meanwhile, please have a look at the patch.
> Link: <https://savannah.gnu.org/bugs/?65451>
> Link: <https://savannah.gnu.org/bugs/?65452>
> Cc: "G. Branden Robinson" <[email protected]>
> Cc: Dave Kemper <[email protected]>
> Cc: "James K. Lowden" <[email protected]>
> Cc: Colin Watson <[email protected]>
> Cc: Werner LEMBERG <[email protected]>
> Signed-off-by: Alejandro Colomar <[email protected]>
> ---
> src/devices/grolbp/lbp.cpp | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
> index c05b42ec3..c28f2e672 100644
> --- a/src/devices/grolbp/lbp.cpp
> +++ b/src/devices/grolbp/lbp.cpp
> @@ -707,10 +707,11 @@ int main(int argc, char **argv)
> case 'w':
> {
> char *ptr;
> + errno = 0;
> long n = strtol(optarg, &ptr, 10);
> if (ptr == optarg)
> error("argument for -w must be a non-negative integer");
> - else if (n < 0 || n > INT_MAX)
> + else if (errno == ERANGE || n < 0 || n > INT_MAX)
> error("out of range argument for -w");
> else
> linewidth_factor = int(n);
> --
> 2.43.0
>
--
<https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature
