Skip to content

Commit

Permalink
libarchive: fix harness and improve build setup (#12052)
Browse files Browse the repository at this point in the history
This fixes a major harness issue in the `libarchive` fuzzer and resolves
a fuzzing roadblock issue related to the build setup.
All calls after `archive_read_add_passphrase` currently exit early
because the decoder state is marked as invalid due to incorrect API
usage.

When combined with libarchive/libarchive#2229,
this should improve coverage from ~15% to >45%.
While the harness issue
[regressed](#9452 (comment))
at some point, it seems like the CRC build flag issue was always present
in oss-fuzz's libarchive setup.

Thanks!
  • Loading branch information
Mrmaxmeier authored Jul 1, 2024
1 parent 80c3ceb commit d5b74d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions projects/libarchive/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ DEPS=/deps

cd $SRC/libarchive

sed -i 's/-Wall//g' ./CMakeLists.txt
sed -i 's/-Werror//g' ./CMakeLists.txt

mkdir build2
cd build2
cmake -DCHECK_CRC_ON_SOLID_SKIP=1 -DDONT_FAIL_ON_CRC_ERROR=1 ../
cmake -DDONT_FAIL_ON_CRC_ERROR=ON -DENABLE_WERROR=OFF ../
make -j$(nproc)

# build seed
Expand Down
4 changes: 2 additions & 2 deletions projects/libarchive/libarchive_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
return 0;
}

archive_read_add_passphrase(a, "secret");

if (ARCHIVE_OK != archive_read_open_memory(a, buf, len)) {
archive_read_free(a);
return 0;
}

archive_read_add_passphrase(a, "secret");

while(1) {
std::vector<uint8_t> data_buffer(getpagesize(), 0);
struct archive_entry *entry;
Expand Down

0 comments on commit d5b74d5

Please sign in to comment.