daemon.c: MHD_select(): check for timeout value overflow

This commit is contained in:
Evgeny Grin (Karlson2k)
2015-08-08 12:29:58 +00:00
parent 9d58eaee1f
commit 066f70ea68
+4 -1
View File
@@ -2364,7 +2364,10 @@ MHD_select (struct MHD_Daemon *daemon,
{
/* ltimeout is in ms */
timeout.tv_usec = (ltimeout % 1000) * 1000;
timeout.tv_sec = ltimeout / 1000;
if (ltimeout / 1000 > TIMEVAL_TV_SEC_MAX)
timeout.tv_sec = TIMEVAL_TV_SEC_MAX;
else
timeout.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE)(ltimeout / 1000);
tv = &timeout;
}
num_ready = MHD_SYS_select_ (max + 1, &rs, &ws, &es, tv);