mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibArchive: Implement proper support for Tar file end markers
Previously this was handled implicitly, as our implementation of Tar would just stop processing input as soon as it found something invalid. However, since we now error out as soon as something is found to be wrong, we require proper handling for zero blocks, which aren't actually fatal.
This commit is contained in:
parent
cb48b9bc30
commit
714f0c3dce
4 changed files with 33 additions and 7 deletions
|
@ -30,6 +30,16 @@ void TarFileHeader::calculate_checksum()
|
|||
VERIFY(String::formatted("{:06o}", expected_checksum()).copy_characters_to_buffer(m_checksum, sizeof(m_checksum)));
|
||||
}
|
||||
|
||||
bool TarFileHeader::is_zero_block() const
|
||||
{
|
||||
u8 const* buffer = reinterpret_cast<u8 const*>(this);
|
||||
for (size_t i = 0; i < sizeof(TarFileHeader); ++i) {
|
||||
if (buffer[i] != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TarFileHeader::content_is_like_extended_header() const
|
||||
{
|
||||
return type_flag() == TarFileType::ExtendedHeader || type_flag() == TarFileType::GlobalExtendedHeader;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue