1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibArchive: Support POSIX.1-1988 tar files

These old tar files didn't have magic numbers, so I've also added a checksum
check to TarInputStream::valid()
This commit is contained in:
Peter Elliott 2021-04-04 18:29:47 -06:00 committed by Andreas Kling
parent a09421f1be
commit dcee024fee
2 changed files with 33 additions and 11 deletions

View file

@ -125,7 +125,14 @@ bool TarInputStream::valid() const
{
auto& header_magic = header().magic();
auto& header_version = header().version();
return (header_magic == gnu_magic && header_version == gnu_version) || (header_magic == ustar_magic && header_version == ustar_version);
if (!((header_magic == gnu_magic && header_version == gnu_version)
|| (header_magic == ustar_magic && header_version == ustar_version)
|| (header_magic == posix1_tar_magic && header_version == posix1_tar_version)))
return false;
// POSIX.1-1988 tar does not have magic numbers, so we also neet to verify the header checksum.
return header().checksum() == header().expected_checksum();
}
TarFileStream TarInputStream::file_contents()