bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix integer overflow test in parse_int


From: Paul Smith
Subject: Re: [PATCH] Fix integer overflow test in parse_int
Date: Thu, 28 Mar 2024 19:28:53 -0400
User-agent: Evolution 3.52.0 (by Flathub.org)

On Sun, 2024-01-07 at 16:09 -0800, Paul Eggert wrote:
> * src/arscan.c (parse_int): Use intprops.h macros rather than trying
> to detect integer overflow by hand, and doing it incorrectly.
> Here is an example of why the old code was incorrect.
> If val == 3689348814741910323, base == 10, *ptr == '0', UINTMAX_WIDTH
> == 64,
> then (val * base) + (*ptr - '0') yields 18446744073709551614,
> which is greater than val even though overflow has occurred.
> Fortunately this bug could not be triggered on GNU/Linux hosts,
> although it may be possible on platforms (if any) where struct ar_hdr
> has members so large that they can represent integers that do not fit
> int uintmax_t.

I applied this, thanks for the patch Paul!

-- 
Paul D. Smith <psmith@gnu.org>            Find some GNU Make tips at:
https://www.gnu.org                       http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad
Scientist






reply via email to

[Prev in Thread] Current Thread [Next in Thread]