gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated: connection_alloc_memory(): fixed


From: gnunet
Subject: [libmicrohttpd] branch master updated: connection_alloc_memory(): fixed missing update of buffers sizes
Date: Sun, 03 Oct 2021 20:08:16 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new 16f6b946 connection_alloc_memory(): fixed missing update of buffers 
sizes
16f6b946 is described below

commit 16f6b9460c6da8f32848bfdfd09cebf8f48d14b5
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Sep 29 15:19:02 2021 +0300

    connection_alloc_memory(): fixed missing update of buffers sizes
---
 src/microhttpd/connection.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 0e0fd5d4..47f9a6ae 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -221,14 +221,18 @@ connection_alloc_memory (struct MHD_Connection 
*connection,
       if (c->write_buffer_size - c->write_buffer_append_offset >= need_to_free)
       {
         char *buf;
+        const size_t new_buf_size = c->write_buffer_size - need_to_free;
         buf = MHD_pool_reallocate (pool,
                                    c->write_buffer,
                                    c->write_buffer_size,
-                                   c->write_buffer_size - need_to_free);
+                                   new_buf_size);
         mhd_assert (c->write_buffer == buf);
 #ifdef NDEBUG
         (void) buf; /* mute compiler warning */
 #endif
+        mhd_assert (c->write_buffer_append_offset <= new_buf_size);
+        mhd_assert (c->write_buffer_send_offset <= new_buf_size);
+        c->write_buffer_size = new_buf_size;
       }
       else
         return NULL;
@@ -239,14 +243,17 @@ connection_alloc_memory (struct MHD_Connection 
*connection,
       if (c->read_buffer_size - c->read_buffer_offset >= need_to_free)
       {
         char *buf;
+        const size_t new_buf_size = c->read_buffer_size - need_to_free;
         buf = MHD_pool_reallocate (pool,
                                    c->read_buffer,
                                    c->read_buffer_size,
-                                   c->read_buffer_size - need_to_free);
+                                   new_buf_size);
         mhd_assert (c->read_buffer == buf);
 #ifdef NDEBUG
         (void) buf; /* mute compiler warning */
 #endif
+        mhd_assert (c->read_buffer_offset <= new_buf_size);
+        c->read_buffer_size = new_buf_size;
       }
       else
         return NULL;

-- 
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]