Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ third_party/
*.idx
debug_parser_stub
.venv/
oom-*
15 changes: 12 additions & 3 deletions fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,17 @@ if(ENABLE_FUZZING)


# Fuzz: parser
add_executable(fuzz_parse fuzz_parse.cpp)
target_compile_options(fuzz_parse PRIVATE ${WSHELL_FUZZ_COMPILE_OPTS})
target_link_options(fuzz_parse PRIVATE ${WSHELL_FUZZ_LINK_OPTS})

add_executable(fuzz_parse_line fuzz_parse_line.cpp)
target_include_directories(fuzz_parse_line PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_options(fuzz_parse_line PRIVATE ${WSHELL_FUZZ_COMPILE_OPTS})
target_link_options(fuzz_parse_line PRIVATE ${WSHELL_FUZZ_LINK_OPTS})
target_link_libraries(fuzz_parse_line PRIVATE wshell_lib)

add_executable(fuzz_parse_program fuzz_parse_program.cpp)
target_include_directories(fuzz_parse_program PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_compile_options(fuzz_parse_program PRIVATE ${WSHELL_FUZZ_COMPILE_OPTS})
target_link_options(fuzz_parse_program PRIVATE ${WSHELL_FUZZ_LINK_OPTS})
target_link_libraries(fuzz_parse_program PRIVATE wshell_lib)

endif()
10 changes: 0 additions & 10 deletions fuzz/fuzz_parse.cpp

This file was deleted.

16 changes: 16 additions & 0 deletions fuzz/fuzz_parse_line.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <cstddef>
#include <cstdint>
#include <string_view>
#include <string>
#include "shell/parser.hpp"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (size == 0) return 0;
std::string input(reinterpret_cast<const char*>(data), size);
try {
auto result = wshell::parse_line(input);
} catch (...) {
// Swallow all exceptions
}
return 0;
}
16 changes: 16 additions & 0 deletions fuzz/fuzz_parse_program.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <cstddef>
#include <cstdint>
#include <string_view>
#include <string>
#include "shell/parser.hpp"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (size == 0) return 0;
std::string input(reinterpret_cast<const char*>(data), size);
try {
auto result = wshell::parse_program(input);
} catch (...) {
// Swallow all exceptions
}
return 0;
}
Loading