From ec853386b06a2d99dabce906601f7316652347c5 Mon Sep 17 00:00:00 2001 From: Gerardo O Date: Mon, 29 Nov 2021 19:49:48 -0600 Subject: [PATCH] Fixed buffer overflow when checking if an HTTP code was a 404 on an empty status code. --- src/parser.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/parser.c b/src/parser.c index ee8374e843..9e21519964 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1521,11 +1521,13 @@ ignore_static (const char *req) { * If the request is a 404, 1 is returned. */ static int is_404 (GLogItem * logitem) { + if (!logitem->status || *logitem->status == '\0') + return 0; /* is this a 404? */ - if (logitem->status && !memcmp (logitem->status, "404", 3)) + if (!memcmp (logitem->status, "404", 3)) return 1; /* treat 444 as 404? */ - else if (logitem->status && !memcmp (logitem->status, "444", 3) && conf.code444_as_404) + else if (!memcmp (logitem->status, "444", 3) && conf.code444_as_404) return 1; return 0; }