Guarantee SSO is not applicable to fallback buffer

This commit is contained in:
Alex Hultman
2019-04-03 03:17:02 +02:00
parent 7f35d06920
commit d4bf6346df
2 changed files with 5 additions and 3 deletions
-2
View File
@@ -57,8 +57,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
/* Parse it */
httpParser.consumePostPadded((char *) data, size, user, [](void *s, uWS::HttpRequest *httpRequest) -> void * {
/* todo: Route this via router */
readBytes(httpRequest->getHeader(httpRequest->getUrl()));
readBytes(httpRequest->getMethod());
readBytes(httpRequest->getQuery());
+5 -1
View File
@@ -29,6 +29,9 @@
namespace uWS {
/* We require at least this much post padding */
static const int MINIMUM_HTTP_POST_PADDING = 32;
class HttpRequest {
friend class HttpParser;
@@ -248,7 +251,8 @@ public:
int maxCopyDistance = std::min(MAX_FALLBACK_SIZE - fallback.length(), (size_t) length);
fallback.reserve(fallback.length() + maxCopyDistance + 32); // todo: padding should be same as libus
/* We don't want fallback to be short string optimized, since we want to move it */
fallback.reserve(fallback.length() + maxCopyDistance + std::max<int>(MINIMUM_HTTP_POST_PADDING, sizeof(std::string)));
fallback.append(data, maxCopyDistance);
// break here on break