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>
With 26 and 27, the sub-test is pushing 2G and 4G memory respectively.
There is no particular reason why we need to push for higher limits
here, so let's pick 23 with weights around 0.25G. The test suite overall
is in the 0.25 - 0.5G range and this fits perfectly.
Closes: https://github.com/libarchive/libarchive/issues/2080
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
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>
The function returns 0 on error, which is seemingly very common with
OpenSSL 3.0 and rmd160.
Just error check the lot, so we don't get even more random failures with
future releases of OpenSSL.
Fixes#1549
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Analogue to the parent cmake commit, with linker flag detection.
The former two split the functions and data into separate sections
within the object file. Which makes it easier for the latter to properly
garbage collect and discard unused sections.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
The former two split the functions and data into separate sections
within the object file. Which makes it easier for the latter to properly
garbage collect and discard unused sections. For example
text data bss dec hex filename
208268 2056 4424 214748 346dc bsdcat -- before
93396 1304 4360 99060 182f4 bsdcat -- after
1059167 12112 24176 1095455 10b71f bsdcpio -- before
1002538 7320 23984 1033842 fc672 bsdcpio -- after
1093676 14248 6608 1114532 1101a4 bsdtar -- before
1062231 14176 6416 1082823 1085c7 bsdtar -- after
1097259 15032 6408 1118699 1111eb libarchive.so.18 -- before
1095675 14992 6216 1116883 110ad3 libarchive.so.18 -- after
Note:
This is enabled only with gcc/clang on non-Mac platforms. Ideally we'll
have a compile-time check, albeit that seems impossible with our ancient
cmake requirement.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
It's fairly common for people to use caf and xaf on Linux. The former in
itself being GNU tar specific - libarchive tar does not allow xa.
While it makes little sense to use xaf with libarchive tar, that is
implementation detail which gets in the way when trying to write trivial
tooling/scripts.
For the sake of compatibility, reduce the error to a warning and augment
the message itself. Making it clear that the option makes little sense.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Prior to version 3.3 cmake would always use -rdynamic. That in itself
causes all the internal symbols to be exported, increasing the binaries
by 5-10% and making it impossible for the compiler to reason, optimise
and discard unused code.
The -rdynamic is useful in two cases:
- having a third party module (say /usr/lib/foo/foobar.so) which is
underlinked and depends on symbols from the main binary - apps like
irssi, bash and zsh use that
- uses the glibc backtrace, which relies on dlopen/dlsym to fetch the
symbol data. Unwind is much better solution, since it replies on the
DWARF data
Our binaries do not use either of these - so drop the -rdynamic. The
autotools build doesn't use it either.
text data bss dec hex filename
229000 2120 4424 235544 39818 bsdcat -- before
208324 2120 4424 214868 34754 bsdcat -- after
1093939 12128 24176 1130243 113f03 bsdcpio -- before
1059181 12128 24176 1095485 10b73d bsdcpio -- after
1130091 14264 6608 1150963 118ff3 bsdtar -- before
1093690 14264 6608 1114562 1101c2 bsdtar -- after
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
The flags used across the two are identical, apart from -g.
There is no compelling reason, why we would omit -g for debug builds
with GCC, while using it with clang.
De-duplicate the sections.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
As before - move the dispatch/function pointer so a const data segment.
Separating it from the RW data section.
Note: the close function is _not_ optional - remove the NULL check.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Analogous to the earlier "can_seek" change. Drop the function pointer
in favour of a flag. Over the years, with over a dozen filters, no
filters actually implemented it.
If at a point in the future that changes, one can reinstate it.
Alternatively one could use a ARCHIVE_FILTER_NONE check.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Currently we the ::seek callback can be either NULL or client_seek_proxy.
Since we already explicitly use the latter, instead of ::seek just drop
the function pointer all together, in favour of a simple flag.
Alternatively one could use a ARCHIVE_FILTER_NONE check.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
There's a notable duplication across all the read bidder code.
Check the archive magic/state, set the bidder private data (to NULL in
all but one case), name and vtable.
Change the helper to do the actual registration, keeping things simpler
in the dozen+ filters. This also allows us to enforce the bidder ::bid
and ::init dispatch are non NULL. The final one ::free is optional.
NOTE: some of the bidders do _not_ set a name, which I suspect is a
pre-existing bug. I've left them as-is, but we might want to fix and
enforce that somehow.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
From over a dozen filters, only one instance has the vfunc... Always
returning ARCHIVE_OK.
Let's just remove the return type.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
There is no point in having stubs around. The caller already checks if
the function pointer is NULL before calling it.
With this in place only one implementation remains in filter_program.
Technically we can rework/remove that as well, although the solution
might not be so clean, so let's keep that for another day.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
None of the filters set ::options and based on git log, none of them
ever did despite that the API/infra was added over 10 years ago.
Let's just drop it, removing the majority of archive_set_filter_option()
which is essentially dead code.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Currently we have a constant dispatch/vtable that we populate at runtime
for unknown reason.
Remove the functions doing all the work and use a simple static const
struct archive_vtable.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Add a simple top-level .editorconfig file to manage common attributes
such as indentation style, trailing whitespace and newline at end of
file. The format is wide spread and has support for nearly every editor
out there - see https://editorconfig.org/ for more.
Majority of the project is C - which uses tabs, although there are some
CMake files using 2 space indent and shell scripts - predominantly using
4 space indent.
This makes it harder for casual contributors to butcher things :-)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Remove the excessive fallthrough chain in parse_keyword(). Even though
it is in the else/error path, there is no point in comparing the key
another dozen (or more) times when we know it will fail.
Just use an early return (OK) or break respectively.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
The call to CloseHandle() is asymmetric and wrong.
The handle is created during the __achive_create_child() call in
__archive_write_program_open() aka the filter open callback.
While CloseHandle() is already called in the filter close callback aka
__archive_write_program_close().
Remove the incorrect call to CloseHandle() from the bidder free callback
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Move the Windows specific to the Windows version of the helper, making
the existing code shorter and simpler.
This means that the child "handle" type will vary across the two
platforms - something that we've already been doing with waitpid.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Change the function to return an int - ARCHIVE_OK or ARCHIVE_FAILED,
taking the child as an output argument.
This will allow us to simplify the existing code and have move platform
specifics in the platform files - posix and windows
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Follow the approach set by the crypto and use the exact same name for
the respective functions. This is perfectly fine, since only one
provider can be used (built) at given time.
As a result, we can kill off the excessively long ifdef chain, making
the more more manageable and shorter.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
To be used by the mtree reader, to populate the internal digest storage.
The function is deliberately not part of the user interface, since it's
interactions are not defined yet.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Allow applications to query the digests stored in the MTREE. Which they
can use at a later stage to perform integrity checks as needed.
Note: no digests are wired yet.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Factor our the md5/rmd160... digests struct, moving it to the private
header. This way we can reuse it within the mtree read code.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>