* window.cc (setitimer): Check for overflow condition

in tv_sec.
This commit is contained in:
Corinna Vinschen 2000-05-09 13:28:11 +00:00
parent 8c63465c7b
commit f26e3f1574
2 changed files with 13 additions and 0 deletions

View File

@ -1,3 +1,9 @@
Thu May 9 15:24:00 2000 Corinna Vinschen <corinna@vinschen.de>
Patch suggested by <lha@stacken.kth.se>
* window.cc (setitimer): Check for overflow condition
in tv_sec.
Thu May 9 0:47:00 2000 Corinna Vinschen <corinna@vinschen.de> Thu May 9 0:47:00 2000 Corinna Vinschen <corinna@vinschen.de>
Patch suggested by Eric Fifer <EFifer@sanwaint.com> Patch suggested by Eric Fifer <EFifer@sanwaint.com>

View File

@ -13,6 +13,7 @@ details. */
#include <sys/time.h> #include <sys/time.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <limits.h>
#include "winsup.h" #include "winsup.h"
static NO_COPY UINT timer_active = 0; static NO_COPY UINT timer_active = 0;
@ -154,6 +155,12 @@ setitimer (int which, const struct itimerval *value, struct itimerval *oldvalue)
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
} }
/* Check if we will wrap */
if (itv.it_value.tv_sec >= (long) (UINT_MAX / 1000))
{
set_errno (EINVAL);
return -1;
}
if (timer_active) if (timer_active)
{ {
KillTimer (gethwnd(), timer_active); KillTimer (gethwnd(), timer_active);