484 Commits

Author SHA1 Message Date
AZero13
55fbf225c8 uname_override checks gname_override when it should check uname_override 2025-12-16 21:44:31 -05:00
Tim Kientzle
96f76577d3 Rename err.h to avoid conflict with system header
Depending on header search path ordering, we can easily
confuse libarchive_fe/err.h with the system header.
Rename ours to lafe_err.h to avoid the confusion.
Rename libarchive_fe/err.c to match.
2025-09-13 12:30:03 -07:00
Tobias Stoeckmann
36bac92cd2 tools: Enforce default handling of SIGCHLD
Ignoring SIGCHLD gets passed to child processes. Doing that has
influence on waitpid, namely that zombie processes won't be
created. This means that a status can never be read.

We can't enforce this in library, but libarchive's tools can be
protected against this by enforcing default handling.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-02 23:29:49 +02:00
Tobias Stoeckmann
612223356e Prefer __CYGWIN__ over CYGWIN definition
The cygwin FAQ states that __CYGWIN__ is defined when building for a
Cygwin environment. Only a few test files check (inconsistently) for
CYGWIN, so adjust them to the recommended __CYGWIN__ definition.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-05-24 11:37:26 +02:00
Graham Percival
b580147278
Fix #endif comments for header guards (#2567) 2025-04-06 14:16:24 -07:00
Silent
14b8803c40
Fix a Y2038 bug by replacing Int32x32To64 with regular multiplication (#2471)
`Int32x32To64` macro internally truncates the arguments to int32, while
`time_t` is 64-bit on most/all modern platforms. Therefore, usage of
this macro creates a Year 2038 bug.

I detailed this issue a while ago in a writeup, and spotted the same
issue in this repository when updating the list of affected
repositories:
<https://cookieplmonster.github.io/2022/02/17/year-2038-problem/>

A few more notes:
1. I changed all uses of `Int32x32To64` en masse, even though at least
one of them was technically OK and used with int32 parameters only. IMO
better safe than sorry.
2. This is untested, but it's a small enough change that I hope the CI
success is a good enough indicator.
2025-01-01 08:31:35 -08:00
Graham Percival
25c3d9afea
Fix compiler nitpicks (#2470) 2024-12-30 19:42:04 -08:00
Graham Percival
982747fd66
Fix compiler nitpicks (#2469) 2024-12-30 13:31:48 -08:00
Graham Percival
edcae6c164
Fix compiler nitpicks (#2465) 2024-12-30 08:30:42 -08:00
Graham Percival
a659a44a85
Fix format strings (#2457) 2024-12-28 11:03:17 -08:00
Zeun
4ebca5ff83
Fix -Werror=warning error and wrap some INSTALL directives with an ENABLE_INSTALL guard (#2397)
1. Fixes build when compiling without ZLIB/BZIP/LZMA `char finishing`
2. All INSTALL directives are now guarded by ENABLE_INSTALL
2024-12-27 12:53:13 -08:00
Mostyn Bramley-Moore
8ac45a813e
Report skipped tests to cmake/ctest (#2429)
This plumbing is required for cmake/ctest to recognise and report
skipped tests.

Now skipped tests in cmake ci jobs are reported like so:
```
          Start   7: libarchive_test_acl_platform_posix1e_read
    7/785 Test   #7: libarchive_test_acl_platform_posix1e_read ................................***Skipped   0.02 sec
```

And there is a list of skipped tests shown at the end of the test run.
2024-12-08 18:07:49 -08:00
Martin Matuška
d8c3b97b31
tests: use const char instead of char in one case (#2381)
Found in test_extract_cpio_absolute_paths.c when compiling FreeBSD base
2024-10-13 13:41:06 -07:00
Emil Velikov
6287b99eb7
Convert the tools and respective tests to SPDX (#2317)
This is the first part of converting the project to use SPDX license
identifiers instead using the verbose license text.

The patches are semi-automated and I've went through manually to ensure
no license changes were made. That said, I would welcome another pair of
eyes, since I am only human.

See https://github.com/libarchive/libarchive/issues/2298

---------

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2024-10-12 20:54:16 -07:00
Mostyn Bramley-Moore
a65f765f17
bsdcpio should exit with an error code if an entry can't be extracted (#2371)
For example if --insecure is not specified, and one of the security
checks fails.
2024-10-07 08:51:17 -07:00
Mostyn Bramley-Moore
62ce582d1c
Simplify tests added in #2363, use testworkdir (#2369) 2024-10-06 20:34:58 -07:00
Dag-Erling Smørgrav
a90e9d84ec
Miscellaneous code cleanup (#2285)
This fixes various code quality issues I encountered while chasing a
memory leak reported by test automation. I failed to reproduce the
memory leak, but I hope you find this useful nonetheless.
2024-10-04 08:45:58 -07:00
Mostyn Bramley-Moore
2fd35b0fdb
Fix ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS on windows (#2363) 2024-10-04 08:36:56 -07:00
Tim Kientzle
3fdf9bf80f
Fix potential overflow warning in cpio test_option_t (#2250)
Fixes an error from #2237.
2024-06-19 16:18:35 -07:00
Tim Kientzle
13c710a825
[cpio test] Dates can be more than 12 bytes, depending on the locale (#2237)
In order to match cpio output, format the reference date with _at least_
12 bytes instead of _exactly_ 12 bytes. This should fix a gratuitous
test failure on certain systems that default to multi-byte locales.
2024-06-16 20:23:11 -07:00
Martin Matuška
826c0afe19
Resolve TODO: Return uname and gname overrides (#2141)
Simplify introducing a struct cpio_owner

Co-authored-by: Rose <83477269+AtariDreams@users.noreply.github.com>
2024-05-13 08:44:28 +02:00
Tobias Stoeckmann
3085a3e9d3
[Windows] Fix test compilation warnings with Visual Studio (#2178)
Fixes all test-related compiler warnings with Visual Studio 2022 on
Windows 11.

Contains some changes from
https://github.com/libarchive/libarchive/pull/2095.

CC: @dunhor

---------

Co-authored-by: Duncan Horn <dunhor@microsoft.com>
2024-05-12 12:26:19 -07:00
Tobias Stoeckmann
bd974e1b7b
tools: Fix stack overflow with many arguments (#2122)
Supplying a lot of "-" arguments to tools can lead to stack overflow due
to recursive *_getopt function calls.

Proof of Concept:

1. Compile libarchive with Visual Studio 2022
2. Call bsdtar with insane amount of arguments
```
PS> bsdtar.exe ("- "*10000).split(" ")
```
The event log shows that bsdtar.exe failed with `0xc00000fd` (stack
overflow).

If compiled with gcc, this does not happen by default because the code
is internally optimized to use this suggested loop instead. You have to
compile with CFLAGS="-O0" to provoke it with gcc as well.
2024-04-12 22:15:53 -07:00
Emil Velikov
d5713db2d4
Minor __LA_NORETURN inspired fixes (#2028)
Earlier MR https://github.com/libarchive/libarchive/pull/2000 forgot to
annotate some functions as __LA_NORETURN. While fixing that I've noticed
that the bsdcat.h header could use some fixes so I've snuck those in.

Kind of make sense to group in one PR, but can split people prefer so.

/cc @AtariDreams fyi

---------

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-12-07 19:22:27 -08:00
AtariDreams
616c7dca2b
Replace __LA_DEAD with __LA_NORETURN (#2000)
Also add the MSC_VER version of the macro.
2023-12-04 08:29:29 -08:00
Brooks Davis
7dde502899
VCSid removal (#2017)
The libarchive source tree is littered with `__FBSDID("$FreeBSD.*")` and
'$FreeBSD$' tags left over from extracting it from FreeBSD's Subversion
repo. They never made sense for a git repo as git doesn't expand them
and FreeBSD has now removed `$FreeBSD$` from most local source files so
these stand out.

In addition to `__FBSDID` I've removed `__RCSID` which was used once for
a `$NetBSD$` expansion. There might be more of a case to be made for
preserving this one as a diff-reduction measure, but it seems mostly
pointless.

This builds and tests pass except for
libarchive_test_read_disk_directory_traversals which failed on master as
well.
2023-11-20 17:41:49 -08:00
Martin Matuska
ee312cfd05 cpio: multiple fixes in list_item_verbose()
Do not call strftime() with NULL timeptr
Adjust uids and gids buffers as cpio_i64toa() may return up to 22 bytes

Fixes #1934
Fixes #1935
2023-07-25 15:20:51 +02:00
Steve Lhomme
9e1081b9a8 Disable CreateFileA calls in UWP builds
Only CreateFile2 and CreateFileFromAppW are allowed.
2023-07-14 00:31:19 +02:00
Steve Lhomme
2aa73f8c94 Use CreateFile2 instead of CreateFileW on Win8+ builds
CreateFileW is not allowed in Universal Windows Platform (UWP) builds but
CreateFile2 is available. We could just enable this code for UWP but
it's probably to use it going forward so the code is properly tested on
both sides.
2023-07-14 00:31:19 +02:00
Bernhard M. Wiedemann
45c728b00d
Fix cpio test in 2038 (#1836)
Without this patch, `bsdcpio_test_option_c` failed after 2038-01-19 with

```
 .../libarchive-3.6.2/cpio/test/test_option_c.c:143: Assertion failed: t >= now - 2
 .../libarchive-3.6.2/cpio/test/test_option_c.c:169: Assertion failed: t >= now - 2
 .../libarchive-3.6.2/cpio/test/test_option_c.c:205: Assertion failed: t >= now - 2
```

Background:
As part of my work on reproducible builds for openSUSE, I check that
software still gives identical build results in the future.
The usual offset is +16 years, because that is how long I expect some
software will be used in some places.
This showed up failing tests in our package build.
See https://reproducible-builds.org/ for why this matters.
2023-01-12 21:27:42 -08:00
Rosen Penev
0348e24bab
replace time64 functions with normal ones (#1830)
Otherwise there are 32/64-bit pointer conversions going on. In Windows
since MSVC2005, time_t has been 64-bit. MinGW needs a hack to get 64-bit
time_t.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-01-09 15:15:55 +01:00
Rosen Penev
2e9bcba706
further cleanup _localtime64_s (#1824)
These were missing from 2d329073435d36065ce30bfd29428f6a45e41016

Signed-off-by: Rosen Penev <rosenp@gmail.com>

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-12-28 23:05:16 +01:00
TERESH1
0025ae8391
Memory leaks fix for tests (#1829)
Issue #1828
2022-12-27 18:30:21 -08:00
Rosen Penev
2d32907343
cleanup _localtime64_s (#1820)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-12-20 13:48:42 +01:00
Martin Matuska
0d7cc9a041 tests: silence localtime() CodeQL warnings
Use localtime_r() or _localtime64_s() if available
2022-12-08 00:24:33 +01:00
Martin Matuška
942cd1a5e1
Merge pull request #1502 from tih/cpio-bin-formats
Support for PWB and v7 binary cpio formats
2021-05-10 21:05:00 +02:00
Rolf Eike Beer
fb1669d9e8
cpio test: add source file extension
Fixes CMake warnings regarding CMP0115.
2021-04-06 18:42:34 +02:00
Tom Ivar Helbekkmo
fe9d6e6c2e update "-h" output with new formats 2021-03-06 22:45:41 +01:00
Tom Ivar Helbekkmo
5ec9c3533e update cpio documentation, add basic test of binary format 2021-03-06 13:04:37 +01:00
Tom Ivar Helbekkmo
809c2e466f fix output format handling and symlink detection for PWB 2021-03-06 10:09:53 +01:00
Tom Ivar Helbekkmo
0d2e5a0502 add -7 option to bsdcpio for symmetry 2021-03-06 09:28:57 +01:00
Tom Ivar Helbekkmo
6c03f55caf add support for reading and writing PWB and V7 cpio archives 2021-03-05 23:18:21 +01:00
Tom Ivar Helbekkmo
af6e8b5bf5 rearrange cpio output format selection 2021-03-05 21:25:06 +01:00
Martin Matuska
33d74f279b
cpio/cpio.c: Fix off-by-one in previous commit 2020-03-02 02:40:40 +01:00
Martin Matuska
ba0478d30e
cpio/cpio.c: avoid calling strlen() for destdir twice 2020-03-02 00:48:47 +01:00
Martin Matuska
4a5fc0b980
bsdcpio_test: from_hex() needs to be an uint32_t
Fixes #1339
2020-02-27 10:42:27 +01:00
zoulasc
343642bcd2
Add printf attributes to the printflike functions used in tests and fix
the format errors.

Closes #1318
2020-01-23 00:19:32 +01:00
Martin Matuska
a11f15860a
Windows: use _localtime64_s and _gmtime64_s where appropriate 2020-01-13 16:16:13 +01:00
Martin Matuska
5be1a96f75
Use localtime_r and gmtime_r if supported
Found by LGTM.com code analysis
2020-01-13 13:39:58 +01:00
Ingo Schwarze
79d841ff93 Minor corrections to the formatting of manual page.
Found with mandoc -Tlint; fixing the following messages:

WARNING: bad NAME section content
WARNING: missing comma before name
WARNING: new sentence, new line
WARNING: parenthesis in function name
WARNING: skipping no-space macro
WARNING: skipping paragraph macro
WARNING: unusual Xr order
WARNING: unusual Xr punctuation
STYLE: no blank before trailing delimiter
STYLE: possible typo in section name
STYLE: trailing delimiter
STYLE: whitespace at end of input line

For the meaning of the messages, see:
https://man.openbsd.org/mandoc#DIAGNOSTICS
2019-09-21 09:23:10 +02:00