]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Prevent usage of uninitialized variable in `__archive_mkstemp` (#2121)
authorTobias Stoeckmann <stoeckmann@users.noreply.github.com>
Sat, 13 Apr 2024 05:14:59 +0000 (05:14 +0000)
committerGitHub <noreply@github.com>
Sat, 13 Apr 2024 05:14:59 +0000 (22:14 -0700)
commit7bc8531da49ed4db1b98416be0b5959266dd19be
tree6378b72ff137fd59b729731191239c18702b364a
parentb5182fa98c4aaf973fbe93597f2ca1025dfda5fe
Prevent usage of uninitialized variable in `__archive_mkstemp` (#2121)

Calling `__archive_mkstemp` can lead to access of an uninitialized
variable in `__archive_mktempx`, because `temp_name` is only initialized
if supplied `template` argument is `NULL`.

If `template` is not `NULL`, it is eventually compared with
`temp_name.s` anyway.

The fix is simple: Always initialize `temp_name`, which merely sets
values in the struct. No memory allocation occurs and the check leads to
the expected result.

How to reproduce:

1. Compile libarchive with Visual Studio 2022 and CMake's Debug profile
2. Run test `bsdtar_test_option_safe_writes`
3. A popup (Microsoft Visual C++ Runtime Library) appears, stating that
variable temp_name is being used without being initialized
libarchive/archive_util.c