-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5eaf5a
commit 94cd2f9
Showing
6 changed files
with
60 additions
and
13 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
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,8 @@ | ||
set(CMAKE_C_COMPILER clang) | ||
set(CMAKE_CXX_COMPILER clang++) | ||
|
||
add_executable(fuzzer src/fuzzer.cpp) | ||
target_compile_options(fuzzer PRIVATE -fsanitize=fuzzer,address) | ||
target_link_libraries(fuzzer PRIVATE -fsanitize=fuzzer,address) | ||
target_link_libraries(fuzzer PRIVATE diagon_lib) | ||
target_set_common(fuzzer) |
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,42 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include "translator/Factory.h" | ||
|
||
int GeneratorInt(const char* data, size_t& size) { | ||
if (size == 0) | ||
return 0; | ||
auto out = int(data[0]); | ||
data++; | ||
size--; | ||
return out; | ||
} | ||
|
||
std::string GeneratorString(const char*& data, size_t& size) { | ||
int index = 0; | ||
while (index < size && data[index]) | ||
++index; | ||
|
||
auto out = std::string(data, data + index); | ||
data += index; | ||
size -= index; | ||
|
||
return out; | ||
} | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) { | ||
auto& translators = TranslatorList(); | ||
auto& translator = translators[GeneratorInt(data, size) % translators.size()]; | ||
std::string input = GeneratorString(data, size); | ||
std::string options = GeneratorString(data, size); | ||
if (translator->Name()) | ||
return 0; | ||
try { | ||
translator->Translate(input, options); | ||
} catch (...) { | ||
} | ||
return 0; // Non-zero return values are reserved for future use. | ||
} | ||
|
||
// Copyright 2021 Arthur Sonzogni. All rights reserved. | ||
// Use of this source code is governed by the MIT license that can be found in | ||
// the LICENSE file. |
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
Empty file.
Empty file.