libmicrohttpd

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

commit a2798b7c7d4707effefc0ac95562670b0161c8d0
parent 4e745237070588d8ceb90302865875723c3b5a2d
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 25 Oct 2021 14:52:39 +0300

Chunked response: close connection if application returns more data than requested

Diffstat:
Msrc/microhttpd/connection.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -1220,6 +1220,13 @@ try_ready_chunked_body (struct MHD_Connection *connection, #endif return MHD_NO; } + if (size_to_fill < (size_t) ret) + { + CONNECTION_CLOSE_ERROR (connection, + _ ("Closing connection (application returned " \ + "more data than requested).")); + return MHD_NO; + } chunk_hdr_len = MHD_uint32_to_strx (ret, chunk_hdr, sizeof(chunk_hdr)); mhd_assert (chunk_hdr_len != 0); mhd_assert (chunk_hdr_len < sizeof(chunk_hdr));