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 url and request parser
- Loading branch information
1 parent
06b74c1
commit 4b7ddb6
Showing
3 changed files
with
56 additions
and
2 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,28 @@ | ||
#include "server/request_parser.hpp" | ||
#include "server/http/request.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::RequestParser; | ||
using osrm::server::http::request; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
auto last = end(in); | ||
|
||
RequestParser parser; | ||
request req; | ||
|
||
// &(*it) is needed to go from iterator to underlying item to pointer to underlying item | ||
parser.parse(req, &(*first), &(*last)); | ||
|
||
escape(&req); | ||
|
||
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,21 @@ | ||
#include "server/api/url_parser.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::api::parseURL; | ||
|
||
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 = parseURL(first, last); | ||
escape(¶m); | ||
|
||
return 0; | ||
} |