[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 01/02: add logic to check return value of MHD_pool_reall
From: |
gnunet |
Subject: |
[libmicrohttpd] 01/02: add logic to check return value of MHD_pool_reallocate() |
Date: |
Wed, 19 Aug 2020 09:58:24 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository libmicrohttpd.
commit 773d6cce732d9bcdde16851926a4e6c92baddd3c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Aug 19 09:41:31 2020 +0200
add logic to check return value of MHD_pool_reallocate()
---
ChangeLog | 4 ++++
src/microhttpd/connection.c | 20 ++++++++++++++++----
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a2e24c02..ee418a04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed 19 Aug 2020 09:40:39 AM CEST
+ Add logic to check on MHD_pool_reallocate() failure reported on the
+ mailinglist (will NOT yet fix the issue). -CG
+
Sun 26 Jul 2020 01:56:54 PM CEST
Add MHD_create_response_from_pipe() to allow creating a response based
on data read from a pipe. -CG
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index ceae1cf8..6666be94 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1147,6 +1147,7 @@ try_grow_read_buffer (struct MHD_Connection *connection,
{
size_t new_size;
size_t avail_size;
+ void *rb;
avail_size = MHD_pool_get_free (connection->pool);
if (0 == avail_size)
@@ -1175,10 +1176,21 @@ try_grow_read_buffer (struct MHD_Connection *connection,
new_size = connection->read_buffer_size + grow_size;
}
/* we can actually grow the buffer, do it! */
- connection->read_buffer = MHD_pool_reallocate (connection->pool,
- connection->read_buffer,
- connection->read_buffer_size,
- new_size);
+ rb = MHD_pool_reallocate (connection->pool,
+ connection->read_buffer,
+ connection->read_buffer_size,
+ new_size);
+ if (NULL == rb)
+ {
+ /* This should NOT be possible: we just computed 'new_size' so that
+ it should fit. If it happens, somehow our read buffer is not in
+ the right position in the pool, say because someone called
+ MHD_pool_allocate() without 'from_end' set to 'true'? Anyway,
+ should be investigated! (Ideally provide all data from
+ *pool and connection->read_buffer and new_size for debugging).
*/mhd_assert (0);
+ return false;
+ }
+ connection->read_buffer = rb;
mhd_assert (NULL != connection->read_buffer);
connection->read_buffer_size = new_size;
return true;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.