From 19e6befddcd4b9a412ea54c28d200a4453a55fcb Mon Sep 17 00:00:00 2001 From: implicitfield <114500360+implicitfield@users.noreply.github.com> Date: Fri, 25 Nov 2022 16:30:45 +0200 Subject: [PATCH] FuzzTar+tar: Advance the stream before continuing Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53733 This bug was caused by a regression introduced in c88d8a2. --- Meta/Lagom/Fuzzers/FuzzTar.cpp | 8 ++++++-- Userland/Utilities/tar.cpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Meta/Lagom/Fuzzers/FuzzTar.cpp b/Meta/Lagom/Fuzzers/FuzzTar.cpp index 5e76197eae7..82c54d9789f 100644 --- a/Meta/Lagom/Fuzzers/FuzzTar.cpp +++ b/Meta/Lagom/Fuzzers/FuzzTar.cpp @@ -19,8 +19,12 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) while (!tar_stream.finished()) { auto const& header = tar_stream.header(); - if (!header.content_is_like_extended_header()) - continue; + if (!header.content_is_like_extended_header()) { + if (tar_stream.advance().is_error()) + return 0; + else + continue; + } switch (header.type_flag()) { case Archive::TarFileType::GlobalExtendedHeader: diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index dca9a189471..48e65b0ccec 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -124,6 +124,7 @@ ErrorOr serenity_main(Main::Arguments arguments) VERIFY_NOT_REACHED(); } + TRY(tar_stream.advance()); continue; } @@ -141,6 +142,7 @@ ErrorOr serenity_main(Main::Arguments arguments) long_name.append(reinterpret_cast(buffer.data()), bytes_read); local_overrides.set("path", long_name.to_string()); + TRY(tar_stream.advance()); continue; } default: