[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd2] 01/21: conn_data_send.c: fixed large sending, added som
From: |
Admin |
Subject: |
[libmicrohttpd2] 01/21: conn_data_send.c: fixed large sending, added some asserts |
Date: |
Fri, 13 Jun 2025 23:38:09 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd2.
commit 1d78defba5cba1f11528098dccb82594a3c24f7e
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
AuthorDate: Fri Jun 13 23:31:43 2025 +0200
conn_data_send.c: fixed large sending, added some asserts
---
src/mhd2/conn_data_send.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/mhd2/conn_data_send.c b/src/mhd2/conn_data_send.c
index 065120b..f602783 100644
--- a/src/mhd2/conn_data_send.c
+++ b/src/mhd2/conn_data_send.c
@@ -199,15 +199,20 @@ mhd_conn_data_send (struct MHD_Connection *restrict c)
if (mhd_REPLY_CNTN_LOC_RESP_BUF == c->rp.cntn_loc)
{
bool complete_response = true;
- size_t send_size =
- (size_t) (c->rp.rsp_cntn_read_pos - resp->cntn_size);
+ const uint_fast64_t send_left =
+ resp->cntn_size - c->rp.rsp_cntn_read_pos;
+ size_t send_size = (size_t) send_left;
+
+ mhd_assert (MHD_SIZE_UNKNOWN != resp->cntn_size);
+ mhd_assert (mhd_HTTP_STAGE_UNCHUNKED_BODY_READY == c->stage);
mhd_assert (mhd_RESPONSE_CONTENT_DATA_BUFFER == resp->cntn_dtype);
mhd_assert (c->rp.rsp_cntn_read_pos < resp->cntn_size);
- if ((c->rp.rsp_cntn_read_pos - resp->cntn_size) != send_size)
+ if (send_left != send_size)
{
send_size = (size_t) ~((size_t) 0);
complete_response = false;
+ mhd_assert (send_left >= send_size);
}
res = mhd_send_data (c,
@@ -216,6 +221,8 @@ mhd_conn_data_send (struct MHD_Connection *restrict c)
+ c->rp.rsp_cntn_read_pos,
complete_response,
&sent);
+ mhd_assert ((mhd_SOCKET_ERR_NO_ERROR != res) ||
+ sent <= send_size);
}
else if (mhd_REPLY_CNTN_LOC_CONN_BUF == c->rp.cntn_loc)
{
@@ -228,6 +235,9 @@ mhd_conn_data_send (struct MHD_Connection *restrict c)
c->write_buffer + c->write_buffer_send_offset,
true,
&sent);
+ mhd_assert ((mhd_SOCKET_ERR_NO_ERROR != res) || \
+ sent <= (c->write_buffer_append_offset \
+ - c->write_buffer_send_offset));
}
else if (mhd_REPLY_CNTN_LOC_IOV == c->rp.cntn_loc)
{
@@ -285,6 +295,7 @@ mhd_conn_data_send (struct MHD_Connection *restrict c)
else
{
c->rp.rsp_cntn_read_pos += sent;
+ mhd_assert (resp->cntn_size >= c->rp.rsp_cntn_read_pos);
if (c->rp.rsp_cntn_read_pos == resp->cntn_size)
c->stage = mhd_HTTP_STAGE_FULL_REPLY_SENT;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd2] branch master updated (cdd4c1f -> a71f9db), Admin, 2025/06/13
- [libmicrohttpd2] 09/21: mhd_str: added 8 bit -> 2 xdigits one-pass encoding, Admin, 2025/06/13
- [libmicrohttpd2] 11/21: mhd_str: optimised caseless comparisons and case transformations, Admin, 2025/06/13
- [libmicrohttpd2] 13/21: parse_http_std_method(): optimised, Admin, 2025/06/13
- [libmicrohttpd2] 21/21: perf_replies: added response sizes 8 MiB and 101 MiB, Admin, 2025/06/13
- [libmicrohttpd2] 02/21: bootstrap: make sure that pre-commit hook really used, Admin, 2025/06/13
- [libmicrohttpd2] 01/21: conn_data_send.c: fixed large sending, added some asserts,
Admin <=
- [libmicrohttpd2] 04/21: xdigittovalue(): optimised., Admin, 2025/06/13
- [libmicrohttpd2] 18/21: Renamed test_postprocessor -> test_postparser to match API naming, Admin, 2025/06/13
- [libmicrohttpd2] 16/21: configure: minor check improvement, Admin, 2025/06/13
- [libmicrohttpd2] 12/21: mhd_locks: added W32 implementation based on SRW locks (and minor improvements), Admin, 2025/06/13
- [libmicrohttpd2] 10/21: configure: added release build linker flags, Admin, 2025/06/13
- [libmicrohttpd2] 15/21: POST parser: improved parsing performance by storing complete delimiter instead of boundary, Admin, 2025/06/13
- [libmicrohttpd2] 14/21: POST parser: optimised large upload processing, Admin, 2025/06/13
- [libmicrohttpd2] 07/21: daemon_start: cosmetics, fixed code style, Admin, 2025/06/13
- [libmicrohttpd2] 06/21: Fixed compiler warnings, Admin, 2025/06/13
- [libmicrohttpd2] 08/21: mhd_str: added functions attributes, fixed doxy, removed extra checks in functions, Admin, 2025/06/13