Open CatyGreen opened 2 years ago
A block of 512 zero bytes is the standard end-of-archive marker in a tar file. So a file that starts with 512 (or more) zero bytes is a valid empty tar file.
Ok, yes. But if the file has more content after the zeroes, libarchive also considers it as a valid tar file.
It is a valid tar file with extra junk following it.
I don't see a reference to this case/behaviour in the documentation; I think it is something that ought to be added.
I can see why some people would be surprised by the handling of a file that starts with 512 zeros.
It might make sense to split our tar handling into two "formats":
We could then include both in archive_read_support_format_all()
to preserve the existing behavior, but folks who specifically wanted to not recognize the empty tar case would have the option of only enabling the other format handler.
This is a small change if someone wanted to give it a shot: just split the existing archive_read_format_tar_bid
to create a new bidder archive_read_format_tar_empty_bid
and use that to construct a new archive_read_format_tar_empty
.
Basic Information Version of libarchive: All of them How you obtained it: (build from source, pre-packaged binary, etc): build from source Operating system and version: Linux Centos 8 What compiler and/or IDE you are using (include version): GCC
Description of the problem you are seeing: What did you do? Run libarchive with a file with at least 512 bytes of zeroes at the begining. What did you expect to happen? Function
archive_read_open_memory
should not return ARCHIVE_OK What actually happened? Functionarchive_read_open_memory
returns ARCHIVE_OK What log files or error messages were produced? NoneHow the libarchive developers can reproduce your problem: What other software was involved? What other files were involved? Test file with all zeroes How can we obtain any of the above? Run
dd if=/dev/zero of=sample_file bs=1 count=512
Debugging the code I reach a function called
archive_read_format_tar_bid
, inside the function there is the following check:The content of
archive_block_is_null
:Why does libarchive make this test?
Thanks.