From 066f70ea6830a65b092b41365a050d681fae44ed Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Sat, 8 Aug 2015 12:29:58 +0000 Subject: [PATCH] daemon.c: MHD_select(): check for timeout value overflow --- src/microhttpd/daemon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 9a94bd92..d45c7487 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -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);