libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit e9e6a5f9d6ed3b328a78c749270733e6fd6c7ba6
parent a6e53c3676feb49046466e8eee1bbae786d3d8c7
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Wed, 24 Nov 2021 16:22:45 +0300

parse_connection_headers(): simplified 'Content-Length' processing

Diffstat:
Msrc/microhttpd/connection.c | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -3543,7 +3543,7 @@ parse_connection_headers (struct MHD_Connection *connection) { const char *clen; const char *enc; - const char *end; + size_t val_len; parse_cookie_header (connection); if ( (1 <= connection->daemon->strict_for_client) && @@ -3589,12 +3589,15 @@ parse_connection_headers (struct MHD_Connection *connection) MHD_STATICSTR_LEN_ ( MHD_HTTP_HEADER_CONTENT_LENGTH), &clen, - NULL)) + &val_len)) { - end = clen + MHD_str_to_uint64_ (clen, - &connection->remaining_upload_size); - if ( (clen == end) || - ('\0' != *end) ) + size_t num_digits; + + num_digits = MHD_str_to_uint64_n_ (clen, + val_len, + &connection->remaining_upload_size); + if ( (val_len != num_digits) || + (0 == num_digits) ) { connection->remaining_upload_size = 0; #ifdef HAVE_MESSAGES