1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:48:11 +00:00

LibArchive: Do not assert if the provided stream cannot be discarded

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52498
This commit is contained in:
implicitfield 2022-11-19 18:34:03 +02:00 committed by Andreas Kling
parent ee0c9ed87b
commit e277185eb1

View file

@ -84,12 +84,11 @@ bool TarFileStream::discard_or_error(size_t count)
TarInputStream::TarInputStream(InputStream& stream)
: m_stream(stream)
{
if (!m_stream.read_or_error(Bytes(&m_header, sizeof(m_header)))) {
if (!m_stream.read_or_error(Bytes(&m_header, sizeof(m_header))) || !m_stream.discard_or_error(block_size - sizeof(TarFileHeader))) {
m_finished = true;
m_stream.handle_any_error(); // clear out errors so we don't assert
return;
}
VERIFY(m_stream.discard_or_error(block_size - sizeof(TarFileHeader)));
}
static constexpr unsigned long block_ceiling(unsigned long offset)