From 430d7251faa8f3eb28a6f58856235f2a6305da1b Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Sun, 26 Dec 2021 11:56:43 +0300 Subject: Reduced maximum possible connection timeout The maximum timeout value is still too large to be used (more than hundred thousand years). --- src/microhttpd/connection.c | 10 +++++----- src/microhttpd/daemon.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 79014352..02fc0e71 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -4999,8 +4999,8 @@ MHD_set_connection_option (struct MHD_Connection *connection, va_start (ap, option); ui_val = va_arg (ap, unsigned int); va_end (ap); -#if (SIZEOF_UINT64_T - 1) <= SIZEOF_UNSIGNED_INT - if ((UINT64_MAX / 2000 - 1) < ui_val) +#if (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT + if ((UINT64_MAX / 4000 - 1) < ui_val) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, @@ -5008,12 +5008,12 @@ MHD_set_connection_option (struct MHD_Connection *connection, "large. Maximum allowed value (%" PRIu64 ") will be used " \ "instead.\n"), ui_val, - (UINT64_MAX / 2000 - 1)); + (UINT64_MAX / 4000 - 1)); #endif - ui_val = UINT64_MAX / 2000 - 1; + ui_val = UINT64_MAX / 4000 - 1; } else -#endif /* (SIZEOF_UINT64_T - 1) <= SIZEOF_UNSIGNED_INT */ +#endif /* (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT */ connection->connection_timeout_ms = ui_val * 1000; if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && (! connection->suspended) ) diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 9f220263..d4064dd7 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -5658,8 +5658,8 @@ parse_options_va (struct MHD_Daemon *daemon, case MHD_OPTION_CONNECTION_TIMEOUT: uv = va_arg (ap, unsigned int); -#if (SIZEOF_UINT64_T - 1) <= SIZEOF_UNSIGNED_INT - if ((UINT64_MAX / 2000 - 1) < uv) +#if (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT + if ((UINT64_MAX / 4000 - 1) < uv) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, @@ -5667,11 +5667,11 @@ parse_options_va (struct MHD_Daemon *daemon, "Maximum allowed value (%" PRIu64 ") will be used " \ "instead.\n"), uv, - (UINT64_MAX / 2000 - 1)); + (UINT64_MAX / 4000 - 1)); #endif - uv = UINT64_MAX / 2000 - 1; + uv = UINT64_MAX / 4000 - 1; } -#endif /* (SIZEOF_UINT64_T - 1) <= SIZEOF_UNSIGNED_INT */ +#endif /* (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT */ daemon->connection_timeout_ms = uv * 1000; break; case MHD_OPTION_NOTIFY_COMPLETED: -- cgit v1.2.3