forked from Project-OSRM/osrm-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fuzz testing drivers for all parameters
- Loading branch information
1 parent
3a0eed2
commit 06b74c1
Showing
9 changed files
with
179 additions
and
40 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 was deleted.
Oops, something went wrong.
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,23 @@ | ||
#include "engine/api/match_parameters.hpp" | ||
#include "server/api/parameters_parser.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::api::parseParameters; | ||
using osrm::engine::api::MatchParameters; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
const auto last = end(in); | ||
|
||
const auto param = parseParameters<MatchParameters>(first, last); | ||
escape(¶m); | ||
|
||
return 0; | ||
} |
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,23 @@ | ||
#include "engine/api/nearest_parameters.hpp" | ||
#include "server/api/parameters_parser.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::api::parseParameters; | ||
using osrm::engine::api::NearestParameters; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
const auto last = end(in); | ||
|
||
const auto param = parseParameters<NearestParameters>(first, last); | ||
escape(¶m); | ||
|
||
return 0; | ||
} |
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,23 @@ | ||
#include "engine/api/route_parameters.hpp" | ||
#include "server/api/parameters_parser.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::api::parseParameters; | ||
using osrm::engine::api::RouteParameters; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
const auto last = end(in); | ||
|
||
const auto param = parseParameters<RouteParameters>(first, last); | ||
escape(¶m); | ||
|
||
return 0; | ||
} |
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,23 @@ | ||
#include "engine/api/table_parameters.hpp" | ||
#include "server/api/parameters_parser.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::api::parseParameters; | ||
using osrm::engine::api::TableParameters; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
const auto last = end(in); | ||
|
||
const auto param = parseParameters<TableParameters>(first, last); | ||
escape(¶m); | ||
|
||
return 0; | ||
} |
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,23 @@ | ||
#include "engine/api/tile_parameters.hpp" | ||
#include "server/api/parameters_parser.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::api::parseParameters; | ||
using osrm::engine::api::TileParameters; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
const auto last = end(in); | ||
|
||
const auto param = parseParameters<TileParameters>(first, last); | ||
escape(¶m); | ||
|
||
return 0; | ||
} |
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,23 @@ | ||
#include "engine/api/trip_parameters.hpp" | ||
#include "server/api/parameters_parser.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::api::parseParameters; | ||
using osrm::engine::api::TripParameters; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
const auto last = end(in); | ||
|
||
const auto param = parseParameters<TripParameters>(first, last); | ||
escape(¶m); | ||
|
||
return 0; | ||
} |
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,16 @@ | ||
#ifndef OSRM_FUZZ_UTIL_HPP | ||
#define OSRM_FUZZ_UTIL_HPP | ||
|
||
#include <type_traits> | ||
|
||
// Fakes observable side effects the compiler can not optimize away | ||
template <typename T> inline void escape(T p) | ||
{ | ||
static_assert(std::is_pointer<T>::value, ""); | ||
asm volatile("" : : "g"((void *)p) : "memory"); | ||
} | ||
|
||
// Possibly reads and writes all the memory in your system | ||
inline void clobber() { asm volatile("" : : : "memory"); } | ||
|
||
#endif |