]> git.ipfire.org Git - thirdparty/tar.git/commit
xsparse cleanup, including integer overflow
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Jul 2024 03:56:27 +0000 (20:56 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 4 Aug 2024 08:41:43 +0000 (01:41 -0700)
commitb26e798a0f79b1aedcddf8eac53e05a073333031
tree3fdf1b5fc709ca69435c5c039fec189aefcaa2dd
parentf22b9fe3ce4ca1580b6a1c3822ecdd26ae2b2c66
xsparse cleanup, including integer overflow

* scripts/xsparse.c: Include inttypes.h, for strtoimax.
Don’t include stdint.h, since inttypes.h includes it.
Sort include directives.
Make all extern functions and vars static, except for ‘main’.
(string_to_off): Use strtoimax instead of doing overflow
checking by hand, incorrectly (it relied on undefined behavior).
(string_to_size): New arg MAXSIZE.  All callers changed.
(get_var): Return bool not int.  Fix unlikely integer overflow.
Use strncmp instead of memcmp, to avoid unlikely pointer overflow.
(read_xheader, read_map, main): Avoid unlikely integer overflow.
Check for I/O errors more consistently.
(main): Prefer bool to int, and put vars near use.
scripts/xsparse.c