From 1d9ed5dcbf2a5f0587acd5066ad950b29fa27f7b Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Mon, 9 Jan 2023 15:48:56 +0000 Subject: [PATCH] Fix invalid read in HttpParamDecode(). --- src/HttpServer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HttpServer.c b/src/HttpServer.c index 2f0a675..efcbc89 100644 --- a/src/HttpServer.c +++ b/src/HttpServer.c @@ -561,7 +561,7 @@ HttpServerWorkerThread(void *args) } requestPath[i] = '\0'; - requestParams = HttpParamDecode(requestPath + i + 1); + requestParams = (i == requestPathLen) ? NULL : HttpParamDecode(requestPath + i + 1); context = HttpServerContextCreate(requestMethod, requestPath, requestParams, fp); if (!context) @@ -591,7 +591,7 @@ HttpServerWorkerThread(void *args) line[i] = tolower(line[i]); } - headerKey = Malloc((i * sizeof(char)) + 1); + headerKey = Malloc((i + 1) * sizeof(char)); if (!headerKey) { goto internal_error;