]> git.ipfire.org Git - thirdparty/tar.git/commit
Port more code to UBSan, and fix alignment bug
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 26 Jul 2025 03:39:32 +0000 (20:39 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 26 Jul 2025 09:20:53 +0000 (02:20 -0700)
commit75735940f1464e45d8fa43169499ad39d5940743
treed021388656bcf557e73c062e71e0b56ab028d8de
parent892113187787c3d8a9fe112e1e85a3a546235bc1
Port more code to UBSan, and fix alignment bug

Problem with extract_file reported by Kirill Furman in:
https://lists.gnu.org/r/bug-tar/2025-07/msg00003.html
Since the UBSan thing seems to be a recurring issue,
I fixed other instances of the problem that I found.
Also, I noticed that the same line of code had another failure to
conform to C23’s rules for pointers (an alignment issue not caught
by UBSan), so I fixed that too.  None of these issues matter on
practical production hosts.
* src/common.h (charptr): New function.
* src/buffer.c (available_space_after, short_read, flush_archive)
(backspace_output, try_new_volume, simple_flush_read)
(_gnu_flush_read, _gnu_flush_write):
* src/compare.c (read_and_process):
* src/create.c (write_eot, write_gnu_long_link)
(dump_regular_file, dump_dir0):
* src/extract.c (extract_file):
* src/incremen.c (get_gnu_dumpdir):
* src/list.c (read_header):
* src/sparse.c (sparse_dump_region, sparse_extract_region):
* src/system.c (sys_write_archive_buffer)
(sys_child_open_for_compress, sys_child_open_for_uncompress):
* src/update.c (append_file, update_archive):
Use it.
* src/buffer.c (set_next_block_after): Arg is now void *,
not union block *, since it need not be a valid union block * pointer
and this can matter on unusual or debugging implementations.
Turn a loop into an if so that the code is O(1) not O(N).
NEWS
src/buffer.c
src/common.h
src/compare.c
src/create.c
src/extract.c
src/incremen.c
src/list.c
src/sparse.c
src/system.c
src/update.c