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)
|
COMMENT "Fuzzing ${binary}" VERBATIM)
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
set(targets
|
|
||||||
|
set(ServerTargets
|
||||||
"match_parameters"
|
"match_parameters"
|
||||||
"nearest_parameters"
|
"nearest_parameters"
|
||||||
"route_parameters"
|
"route_parameters"
|
||||||
@ -40,8 +41,18 @@ if (ENABLE_FUZZING)
|
|||||||
"url_parser"
|
"url_parser"
|
||||||
"request_parser")
|
"request_parser")
|
||||||
|
|
||||||
foreach (target ${targets})
|
foreach (target ${ServerTargets})
|
||||||
add_fuzz_target(${target})
|
add_fuzz_target(${target})
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
|
||||||
|
set(UtilTargets
|
||||||
|
"escape_json"
|
||||||
|
"uri_decode")
|
||||||
|
|
||||||
|
foreach (target ${UtilTargets})
|
||||||
|
add_fuzz_target(${target})
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
|
||||||
endif ()
|
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