aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-19 09:41:31 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-19 09:41:31 +0200
commit773d6cce732d9bcdde16851926a4e6c92baddd3c (patch)
treeab511cdd994bcd5bc9bd0cb7a81d471388cf4a16
parentbade8d9c4b5c1c6ab8b38a68ce57f8593177763c (diff)
downloadlibmicrohttpd-773d6cce732d9bcdde16851926a4e6c92baddd3c.tar.gz
libmicrohttpd-773d6cce732d9bcdde16851926a4e6c92baddd3c.zip
add logic to check return value of MHD_pool_reallocate()
-rw-r--r--ChangeLog4
-rw-r--r--src/microhttpd/connection.c20
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 @@
1Wed 19 Aug 2020 09:40:39 AM CEST
2 Add logic to check on MHD_pool_reallocate() failure reported on the
3 mailinglist (will NOT yet fix the issue). -CG
4
1Sun 26 Jul 2020 01:56:54 PM CEST 5Sun 26 Jul 2020 01:56:54 PM CEST
2 Add MHD_create_response_from_pipe() to allow creating a response based 6 Add MHD_create_response_from_pipe() to allow creating a response based
3 on data read from a pipe. -CG 7 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,
1147{ 1147{
1148 size_t new_size; 1148 size_t new_size;
1149 size_t avail_size; 1149 size_t avail_size;
1150 void *rb;
1150 1151
1151 avail_size = MHD_pool_get_free (connection->pool); 1152 avail_size = MHD_pool_get_free (connection->pool);
1152 if (0 == avail_size) 1153 if (0 == avail_size)
@@ -1175,10 +1176,21 @@ try_grow_read_buffer (struct MHD_Connection *connection,
1175 new_size = connection->read_buffer_size + grow_size; 1176 new_size = connection->read_buffer_size + grow_size;
1176 } 1177 }
1177 /* we can actually grow the buffer, do it! */ 1178 /* we can actually grow the buffer, do it! */
1178 connection->read_buffer = MHD_pool_reallocate (connection->pool, 1179 rb = MHD_pool_reallocate (connection->pool,
1179 connection->read_buffer, 1180 connection->read_buffer,
1180 connection->read_buffer_size, 1181 connection->read_buffer_size,
1181 new_size); 1182 new_size);
1183 if (NULL == rb)
1184 {
1185 /* This should NOT be possible: we just computed 'new_size' so that
1186 it should fit. If it happens, somehow our read buffer is not in
1187 the right position in the pool, say because someone called
1188 MHD_pool_allocate() without 'from_end' set to 'true'? Anyway,
1189 should be investigated! (Ideally provide all data from
1190 *pool and connection->read_buffer and new_size for debugging). */mhd_assert (0);
1191 return false;
1192 }
1193 connection->read_buffer = rb;
1182 mhd_assert (NULL != connection->read_buffer); 1194 mhd_assert (NULL != connection->read_buffer);
1183 connection->read_buffer_size = new_size; 1195 connection->read_buffer_size = new_size;
1184 return true; 1196 return true;