Skip to content

Commit

Permalink
Make fuzzer use new buffer interface rather than a tempfile
Browse files Browse the repository at this point in the history
  • Loading branch information
SaladDais committed Oct 29, 2022
1 parent 1508569 commit 11434d0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 75 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
build
build_fuzz
*.tar.bz2
*.tar.zstd
cmake-build-*
*.o
*~
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ if (TAILSLIDE_BUILD_FUZZER)
fuzz/fuzz.cc
)
target_sources(tailslide_fuzzer PRIVATE
fuzz/fuzz_utils.hh
)
target_include_directories(tailslide_fuzzer PUBLIC ${CMAKE_CURRENT_BINARY_DIR} libtailslide)
target_link_libraries(tailslide_fuzzer PUBLIC ${EXTRA_LIBS} libtailslide "-fsanitize=fuzzer,address")
Expand Down
14 changes: 14 additions & 0 deletions fuzz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#1/bin/bash

set -e

pushd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null

mkdir -p build_fuzz
pushd build_fuzz
mkdir -p fuzz_inputs

find ../tests/ -name "*.lsl" | grep -v "/expected/" | xargs -I'{}' cp '{}' fuzz_inputs/
CXX=clang++ CC=clang cmake .. -DTAILSLIDE_BUILD_FUZZER=on
cmake --build .
./tailslide-fuzzer ./fuzz_inputs/ -fork=8
12 changes: 1 addition & 11 deletions fuzz/fuzz.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <iostream>

#include "fuzz_utils.hh"
#include "tailslide.hh"
#include "passes/tree_simplifier.hh"
#include "passes/lso/script_compiler.hh"
Expand All @@ -19,14 +18,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
compile_cil = getenv("COMPILE_CIL") != nullptr;
}

const char *file = buf_to_file(data, size);
if (!file) {
exit(EXIT_FAILURE);
}

Tailslide::ScopedScriptParser parser(nullptr);
try {
auto *script = parser.parseLSLFile(file);
auto *script = parser.parseLSLBytes((const char *)data, size);
if (script) {
script->collectSymbols();
script->determineTypes();
Expand Down Expand Up @@ -65,9 +59,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
std::cout << e.what() << std::endl;
}

if (delete_file(file) != 0) {
exit(EXIT_FAILURE);
}

return EXIT_SUCCESS;
}
63 changes: 0 additions & 63 deletions fuzz/fuzz_utils.hh

This file was deleted.

0 comments on commit 11434d0

Please sign in to comment.