-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathEWSFuzz.c
executable file
·24 lines (22 loc) · 1.02 KB
/
EWSFuzz.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#define EWS_FUZZ_TEST 1
#include "../EmbeddableWebServer.h"
struct Server server;
int main(int argc, const char* argv[]) {
printf("%d\n", RequestParseStateBadRequest);
serverInit(&server);
struct Connection* connection = connectionAlloc(&server);
struct sockaddr_in* simulated = (struct sockaddr_in*) &connection->remoteAddr;
simulated->sin_addr.s_addr = INADDR_LOOPBACK;
simulated->sin_family = AF_INET;
simulated->sin_port = htons(8080);
connection->socketfd = STDIN_FILENO;
connectionHandlerThread(connection);
return 0;
}
struct Response* createResponseForRequest(const struct Request* request, struct Connection* connection) {
//char* strdupDecodePOSTParam(const char* paramNameIncludingEquals, const struct Request* request, const char* valueIfNotFound)
char* message = strdupDecodePOSTParam("message=", request, "");
printf("%s\n", message);
free(message);
return responseAllocServeFileFromRequestPath("/", request->path, request->pathDecoded, "fuzz-test-document-root");
}