Add fuzz testing drivers for json escaping and uri decoding
This commit is contained in:
parent
4b7ddb6826
commit
cdf6baba1d
@ -30,7 +30,8 @@ if (ENABLE_FUZZING)
|
||||
COMMENT "Fuzzing ${binary}" VERBATIM)
|
||||
endmacro ()
|
||||
|
||||
set(targets
|
||||
|
||||
set(ServerTargets
|
||||
"match_parameters"
|
||||
"nearest_parameters"
|
||||
"route_parameters"
|
||||
@ -40,8 +41,18 @@ if (ENABLE_FUZZING)
|
||||
"url_parser"
|
||||
"request_parser")
|
||||
|
||||
foreach (target ${targets})
|
||||
add_fuzz_target(${target})
|
||||
foreach (target ${ServerTargets})
|
||||
add_fuzz_target(${target})
|
||||
endforeach ()
|
||||
|
||||
|
||||
set(UtilTargets
|
||||
"escape_json"
|
||||
"uri_decode")
|
||||
|
||||
foreach (target ${UtilTargets})
|
||||
add_fuzz_target(${target})
|
||||
endforeach ()
|
||||
|
||||
|
||||
endif ()
|
||||
|
18
fuzz/escape_json.cc
Normal file
18
fuzz/escape_json.cc
Normal file
@ -0,0 +1,18 @@
|
||||
#include "util/string_util.hpp"
|
||||
|
||||
#include "util.hpp"
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
using osrm::util::escape_JSON;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size)
|
||||
{
|
||||
const std::string in(reinterpret_cast<const char *>(data), size);
|
||||
|
||||
const auto escaped = escape_JSON(in);
|
||||
escape(escaped.data());
|
||||
|
||||
return 0;
|
||||
}
|
21
fuzz/uri_decode.cc
Normal file
21
fuzz/uri_decode.cc
Normal file
@ -0,0 +1,21 @@
|
||||
#include "server/api/url_parser.hpp"
|
||||
#include "util/string_util.hpp"
|
||||
|
||||
#include "util.hpp"
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
using osrm::util::URIDecode;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size)
|
||||
{
|
||||
const std::string in(reinterpret_cast<const char *>(data), size);
|
||||
std::string out;
|
||||
|
||||
(void)URIDecode(in, out);
|
||||
|
||||
escape(out.data());
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user