gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]