libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit 7b091bbfbd6525631a73f6c6ec07a7cd45ef936d
parent 364bb08104c98f434b557206c238723cd4e14c79
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Tue, 30 Dec 2025 20:52:33 +0100

Fixed harmless zero-termination over existing zero-termination

This is a fix for the sanitizer error.

Diffstat:
Msrc/mhd2/stream_process_request.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mhd2/stream_process_request.c b/src/mhd2/stream_process_request.c @@ -2465,7 +2465,8 @@ parse_cookies_string (const size_t str_len, return MHD_PARSE_COOKIE_MALFORMED; /* Garbage at the end of the cookie value */ } mhd_assert (0 != name_len); - str[name_start + name_len] = 0; /* Zero-terminate the name */ + if (value_start + value_len < str_len) + str[name_start + name_len] = '\0'; /* Zero-terminate the name */ if (0 != value_len) { struct MHD_String name; @@ -2473,7 +2474,8 @@ parse_cookies_string (const size_t str_len, mhd_assert (value_start + value_len <= str_len); name.cstr = str + name_start; name.len = name_len; - str[value_start + value_len] = 0; /* Zero-terminate the value */ + if (value_start + value_len < str_len) + str[value_start + value_len] = '\0'; /* Zero-terminate the value */ value.cstr = str + value_start; value.len = value_len; if (! mhd_stream_add_field (s,