-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasm/test: Set up fuzzing of the module validation
- Loading branch information
1 parent
834fd1b
commit e293c43
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-FileCopyrightText: 2024 Robin Lindén <[email protected]> | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
|
||
#include "wasm/validation.h" | ||
|
||
#include "wasm/byte_code_parser.h" | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <sstream> | ||
#include <string> | ||
#include <tuple> | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(std::uint8_t const *data, std::size_t size); | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(std::uint8_t const *data, std::size_t size) { | ||
auto module = wasm::ByteCodeParser::parse_module( | ||
std::stringstream{std::string{reinterpret_cast<char const *>(data), size}}); | ||
if (!module) { | ||
return 0; | ||
} | ||
|
||
std::ignore = wasm::validation::validate(*module); | ||
return 0; | ||
} |