]> git.ipfire.org Git - thirdparty/make.git/commit
* src/arscan.c (parse_int): Fix integer overflow test
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 8 Jan 2024 00:09:49 +0000 (16:09 -0800)
committerPaul Smith <psmith@gnu.org>
Thu, 28 Mar 2024 23:08:13 +0000 (19:08 -0400)
commit61ee4578f59e4478bf76fa584b199e1a22521cb0
tree68b52f05e6c78e0517eaf988d840b5c1636cdecf
parentf289ece6cf6188cc2be4273acf2ecf0394743fc5
* src/arscan.c (parse_int): Fix integer overflow test

Use intprops.h macros rather than trying to detect integer overflow by
hand, and doing it incorrectly.  Example of incorrect behavior:
if val == 3689348814741910323, base == 10, UINTMAX_WIDTH == 64, and
 *ptr == '0' 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.
src/arscan.c