blob: 45d4cd9a02081f97e71cdf403da5aaf27399e3f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/*
* 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;
while (!tar_stream.finished()) {
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;
}
auto maybe_error = tar_stream.advance();
if (maybe_error.is_error())
return 0;
}
return 0;
}
|