Re: [hackers] [quark][PATCH] Fix overflow when calling strtonum in parse_range

From: José Miguel Sánchez García <soy.jmi2k_AT_gmail.com>
Date: Sun, 1 Nov 2020 01:15:32 +0100

On 10/31/2020 11:27 PM, Laslo Hunhold wrote:

> this is a great catch, thanks! But wouldn't it be better to use
> MIN(SIZE_MAX, LLONG_MAX)?
>
> I haven't found anything in the standard that puts "long long" and
> "size_t" into any relation, which means, for me, that any case is
> possible where either value could be larger, but please correct me if
> I'm wrong.

Good point! It could be the case that SIZE_MAX is smaller than
LLONG_MAX. Honestly I don't know, but I would do what you are proposing
just to be sure: it is the safest option, and maybe the compiler will
take care of replacing the correct value at compile time. Way better
than leaving another bug lingering until someone else finds it again.

Best regards,
José Miguel
Received on Sun Nov 01 2020 - 01:15:32 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 01 2020 - 01:24:32 CET