Add PerMessageDeflate fuzz target

This commit is contained in:
Alex Hultman
2019-06-09 21:52:53 +02:00
parent bc6ea664b1
commit 8329285ef1
3 changed files with 41 additions and 1 deletions
+2 -1
View File
@@ -3,4 +3,5 @@ default:
clang++ -std=c++17 -fsanitize=address,fuzzer -O3 WebSocket.cpp -o WebSocket
clang++ -std=c++17 -fsanitize=address,fuzzer -O3 Http.cpp -o Http
clang++ -std=c++17 -fsanitize=address,fuzzer -O3 Extensions.cpp -o Extensions
clang++ -std=c++17 -fsanitize=address,fuzzer -O3 Handshake.cpp -o Handshake
clang++ -std=c++17 -fsanitize=address,fuzzer -O3 Handshake.cpp -o Handshake
clang++ -std=c++17 -fsanitize=address,fuzzer -O3 PerMessageDeflate.cpp -o PerMessageDeflate -lz
+38
View File
@@ -0,0 +1,38 @@
/* This is a fuzz test of the permessage-deflate module */
#define WIN32_EXPORT
#include <cstdio>
#include <string>
/* We test the permessage deflate module */
#include "../src/PerMessageDeflate.h"
#include "helpers.h"
struct StaticData {
uWS::ZlibContext zlibContext;
uWS::InflationStream inflationStream;
uWS::DeflationStream deflationStream;
} staticData;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
/* Why is this padded? */
makeChunked(makePadded(data, size), size, [](const uint8_t *data, size_t size) {
std::string_view inflation = staticData.inflationStream.inflate(&staticData.zlibContext, std::string_view((char *) data, size), 256);
if (inflation.length() > 256) {
/* Cause ASAN to freak out */
//delete (int *) (void *) 1;
}
});
makeChunked(makePadded(data, size), size, [](const uint8_t *data, size_t size) {
/* Always reset */
staticData.deflationStream.deflate(&staticData.zlibContext, std::string_view((char *) data, size), true);
});
return 0;
}
+1
View File
@@ -9,6 +9,7 @@ Currently the following parts are individually tested:
* WebSocket handshake generator
* WebSocket message parser
* WebSocket extensions parser & negotiator
* WebSocket permessage-deflate compression/inflation helper
* Http parser
* Http method/url router