libmicrohttpd

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

commit 8a69a4492345c359ab804109d97efb7e292a2c7b
parent eebf9c28f01fdcd970a9f9496487930fe9eb4cea
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 22 Nov 2021 21:37:44 +0300

process_request_body(): fixed: do not skip chunk closure when too few data available

Diffstat:
Msrc/microhttpd/connection.c | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -3113,17 +3113,20 @@ process_request_body (struct MHD_Connection *connection) mhd_assert (MHD_SIZE_UNKNOWN == connection->remaining_upload_size); if ( (connection->current_chunk_offset == connection->current_chunk_size) && - (0LLU != connection->current_chunk_offset) && - (available >= 2) ) + (0 != connection->current_chunk_size) ) { size_t i; + mhd_assert (0 != available); /* skip new line at the *end* of a chunk */ i = 0; - if ( ('\r' == buffer_head[i]) && - ('\n' == buffer_head[i + 1]) ) + if ( (2 <= available) && + ('\r' == buffer_head[0]) && + ('\n' == buffer_head[1]) ) i += 2; /* skip CRLF */ - else if ('\n' == buffer_head[i]) /* TODO: Add MHD option to disallow */ + else if ('\n' == buffer_head[0]) /* TODO: Add MHD option to disallow */ i++; /* skip bare LF */ + else if (2 > available) + break; /* need more upload data */ if (0 == i) { /* malformed encoding */