mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 06:04:57 +00:00
LibArchive: Read Tar archive headers through read_value
This commit is contained in:
parent
b623dda765
commit
26ba195cf6
2 changed files with 6 additions and 4 deletions
|
@ -155,3 +155,8 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Traits<Archive::TarFileHeader> : public AK::GenericTraits<Archive::TarFileHeader> {
|
||||
static constexpr bool is_trivially_serializable() { return true; }
|
||||
};
|
||||
|
|
|
@ -92,10 +92,7 @@ ErrorOr<void> TarInputStream::load_next_header()
|
|||
{
|
||||
size_t number_of_consecutive_zero_blocks = 0;
|
||||
while (true) {
|
||||
// FIXME: This should read the entire span.
|
||||
auto header_span = TRY(m_stream->read_some(Bytes(&m_header, sizeof(m_header))));
|
||||
if (header_span.size() != sizeof(m_header))
|
||||
return Error::from_string_literal("Failed to read the entire header");
|
||||
m_header = TRY(m_stream->read_value<TarFileHeader>());
|
||||
|
||||
// Discard the rest of the header block.
|
||||
TRY(m_stream->discard(block_size - sizeof(TarFileHeader)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue