Reduced maximum possible connection timeout

The maximum timeout value is still too large to be used (more than
hundred thousand years).
This commit is contained in:
Evgeny Grin (Karlson2k)
2021-12-26 12:41:48 +03:00
parent 005d1f25b2
commit 430d7251fa
2 changed files with 10 additions and 10 deletions
+5 -5
View File
@@ -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) )
+5 -5
View File
@@ -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: