mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 11:09:05 +03:00
Fuzzers: Add fuzzer for the Tar parser
This commit is contained in:
parent
9e6475d76d
commit
9f3de0be6a
Notes:
sideshowbarker
2024-07-17 05:41:39 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/9f3de0be6a Pull-request: https://github.com/SerenityOS/serenity/pull/15635 Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/timschumi
@ -61,6 +61,7 @@ add_simple_fuzzer(FuzzSHA384 LibCrypto)
|
||||
add_simple_fuzzer(FuzzSHA512 LibCrypto)
|
||||
add_simple_fuzzer(FuzzShell LibShell)
|
||||
add_simple_fuzzer(FuzzSQLParser LibSQL)
|
||||
add_simple_fuzzer(FuzzTar LibArchive)
|
||||
add_simple_fuzzer(FuzzTTF LibGfx)
|
||||
add_simple_fuzzer(FuzzURL)
|
||||
add_simple_fuzzer(FuzzUTF16BEDecoder LibTextCodec)
|
||||
|
39
Meta/Lagom/Fuzzers/FuzzTar.cpp
Normal file
39
Meta/Lagom/Fuzzers/FuzzTar.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <LibArchive/TarStream.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||
{
|
||||
InputMemoryStream input_stream(ReadonlyBytes { data, size });
|
||||
Archive::TarInputStream tar_stream(input_stream);
|
||||
|
||||
if (!tar_stream.valid())
|
||||
return 0;
|
||||
|
||||
for (; !tar_stream.finished(); tar_stream.advance()) {
|
||||
auto const& header = tar_stream.header();
|
||||
|
||||
if (!header.content_is_like_extended_header())
|
||||
continue;
|
||||
|
||||
switch (header.type_flag()) {
|
||||
case Archive::TarFileType::GlobalExtendedHeader:
|
||||
case Archive::TarFileType::ExtendedHeader: {
|
||||
auto result = tar_stream.for_each_extended_header([&](StringView, StringView) {});
|
||||
if (result.is_error())
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user