[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 20/29: Added checks for correct values specified for con
From: |
gnunet |
Subject: |
[libmicrohttpd] 20/29: Added checks for correct values specified for connection memory limits |
Date: |
Tue, 20 Jun 2023 22:24:33 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit c1b6751c11314d046c87ea83ef611d95c44e2be7
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Jun 14 13:46:54 2023 +0300
Added checks for correct values specified for connection memory limits
---
src/include/microhttpd.h | 6 ++++--
src/microhttpd/daemon.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 4976b071..8745367c 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -96,7 +96,7 @@ extern "C"
* they are parsed as decimal numbers.
* Example: 0x01093001 = 1.9.30-1.
*/
-#define MHD_VERSION 0x00097702
+#define MHD_VERSION 0x00097703
/* If generic headers don't work on your platform, include headers
which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t',
@@ -1626,6 +1626,7 @@ enum MHD_OPTION
* Values above 128k are unlikely to result in much benefit, as half
* of the memory will be typically used for IO, and TCP buffers are
* unlikely to support window sizes above 64k on most systems.
+ * Values below 64 bytes are completely unusable.
*/
MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1,
@@ -1864,7 +1865,8 @@ enum MHD_OPTION
/**
* Increment to use for growing the read buffer (followed by a
- * `size_t`). Must fit within #MHD_OPTION_CONNECTION_MEMORY_LIMIT.
+ * `size_t`).
+ * Must not be higher than 1/4 of #MHD_OPTION_CONNECTION_MEMORY_LIMIT.
*/
MHD_OPTION_CONNECTION_MEMORY_INCREMENT = 21,
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f310e1c7..c403d02b 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -6250,10 +6250,41 @@ parse_options_va (struct MHD_Daemon *daemon,
case MHD_OPTION_CONNECTION_MEMORY_LIMIT:
daemon->pool_size = va_arg (ap,
size_t);
+ if (64 > daemon->pool_size)
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _ ("Warning: specified MHD_OPTION_CONNECTION_MEMORY_LIMIT " \
+ "value is too small and rounded up to 64.\n"));
+#endif /* HAVE_MESSAGES */
+ daemon->pool_size = 64;
+ }
+ if (daemon->pool_size / 4 < daemon->pool_increment)
+ daemon->pool_increment = daemon->pool_size / 4;
break;
case MHD_OPTION_CONNECTION_MEMORY_INCREMENT:
daemon->pool_increment = va_arg (ap,
size_t);
+ if (0 == daemon->pool_increment)
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _ ("The MHD_OPTION_CONNECTION_MEMORY_INCREMENT value " \
+ "cannot be zero.\n"));
+#endif /* HAVE_MESSAGES */
+ return MHD_NO;
+ }
+ if (daemon->pool_size / 4 < daemon->pool_increment)
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _ ("Warning: specified " \
+ "MHD_OPTION_CONNECTION_MEMORY_INCREMENT value is too " \
+ "large and rounded down to 1/4 of " \
+ "MHD_OPTION_CONNECTION_MEMORY_LIMIT.\n"));
+#endif /* HAVE_MESSAGES */
+ daemon->pool_increment = daemon->pool_size / 4;
+ }
break;
case MHD_OPTION_CONNECTION_LIMIT:
daemon->connection_limit = va_arg (ap,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 06/29: Re-implemented parsing of the request headers and footers from scratch., (continued)
- [libmicrohttpd] 06/29: Re-implemented parsing of the request headers and footers from scratch., gnunet, 2023/06/20
- [libmicrohttpd] 12/29: Added back testing with socat as a fallback option, gnunet, 2023/06/20
- [libmicrohttpd] 05/29: Request body processing: removed impossible code paths, gnunet, 2023/06/20
- [libmicrohttpd] 16/29: Added tests with single and double folded header, gnunet, 2023/06/20
- [libmicrohttpd] 21/29: process_request_body(): minor readability improvementы, gnunet, 2023/06/20
- [libmicrohttpd] 11/29: testzzuf: re-worked zzuf testing, gnunet, 2023/06/20
- [libmicrohttpd] 10/29: testzzuf: added special debug functions, gnunet, 2023/06/20
- [libmicrohttpd] 22/29: Minor refactoring for partially processed request body, gnunet, 2023/06/20
- [libmicrohttpd] 14/29: Added test with folded header placed last, gnunet, 2023/06/20
- [libmicrohttpd] 15/29: Added test with large folded header, gnunet, 2023/06/20
- [libmicrohttpd] 20/29: Added checks for correct values specified for connection memory limits,
gnunet <=
- [libmicrohttpd] 19/29: connection: fixed pipelined requests processing, gnunet, 2023/06/20
- [libmicrohttpd] 13/29: Added new tests with header fold, gnunet, 2023/06/20
- [libmicrohttpd] 18/29: Added proper connection's buffers pre-initialisaion, gnunet, 2023/06/20
- [libmicrohttpd] 17/29: connection.c: corrected error responses, gnunet, 2023/06/20
- [libmicrohttpd] 24/29: process new connection: fixed missing mutex unlock in error handling path, gnunet, 2023/06/20
- [libmicrohttpd] 23/29: Adjusted buffer increase default step size, gnunet, 2023/06/20
- [libmicrohttpd] 28/29: try_grow_read_buffer(): better handling of edge cases, gnunet, 2023/06/20
- [libmicrohttpd] 26/29: W32 VS Projects: fixed code parsing, gnunet, 2023/06/20
- [libmicrohttpd] 27/29: Fixed some comments, gnunet, 2023/06/20
- [libmicrohttpd] 25/29: Fixed possible timeout value trim on 32-bits platforms, gnunet, 2023/06/20