mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-13 17:00:40 +00:00
Fuzz Server::handle_file_request through a mount point backed by a temporary directory that holds symlinks escaping the mount root, one of them into a sibling directory sharing its name prefix. Abort if a token stored outside the root appears in a response. The seeds are based on those of #2661. Move FuzzedStream into fuzzed_stream.h so that both server fuzzers share it, and add FuzzableServer::MarkAsRunning(), without which a server that is not listening writes no file.
38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
#include "fuzzed_stream.h"
|
|
|
|
static FuzzableServer g_server;
|
|
|
|
extern "C" int LLVMFuzzerInitialize(int * /*argc*/, char *** /*argv*/) {
|
|
g_server.Get(R"(.*)",
|
|
[&](const httplib::Request & /*req*/, httplib::Response &res) {
|
|
res.set_content("response content", "text/plain");
|
|
});
|
|
g_server.Post(R"(.*)",
|
|
[&](const httplib::Request & /*req*/, httplib::Response &res) {
|
|
res.set_content("response content", "text/plain");
|
|
});
|
|
g_server.Put(R"(.*)",
|
|
[&](const httplib::Request & /*req*/, httplib::Response &res) {
|
|
res.set_content("response content", "text/plain");
|
|
});
|
|
g_server.Patch(R"(.*)",
|
|
[&](const httplib::Request & /*req*/, httplib::Response &res) {
|
|
res.set_content("response content", "text/plain");
|
|
});
|
|
g_server.Delete(
|
|
R"(.*)", [&](const httplib::Request & /*req*/, httplib::Response &res) {
|
|
res.set_content("response content", "text/plain");
|
|
});
|
|
g_server.Options(
|
|
R"(.*)", [&](const httplib::Request & /*req*/, httplib::Response &res) {
|
|
res.set_content("response content", "text/plain");
|
|
});
|
|
return 0;
|
|
}
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
FuzzedStream stream{data, size};
|
|
g_server.ProcessFuzzedRequest(stream);
|
|
return 0;
|
|
}
|