From df2ba4c724bc66adba0ab7f2ea15edc6bd045d49 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 10 Nov 2023 21:03:28 +0100 Subject: [PATCH] Fix escape_html() crashing for NULL input Signed-off-by: DL6ER --- src/webserver/http-common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webserver/http-common.c b/src/webserver/http-common.c index f7521dac..c1fdc275 100644 --- a/src/webserver/http-common.c +++ b/src/webserver/http-common.c @@ -524,6 +524,10 @@ void read_and_parse_payload(struct ftl_conn *api) // See https://www.w3.org/International/questions/qa-escapes#use char *__attribute__((malloc)) escape_html(const char *string) { + // If the string is NULL, return NULL + if(string == NULL) + return NULL; + // Allocate memory for escaped string char *escaped = calloc(strlen(string) * 6 + 1, sizeof(char)); if(!escaped)