OSDN Git Service

* window.cc (setitimer): Check for overflow condition
authorcorinna <corinna>
Tue, 9 May 2000 13:28:11 +0000 (13:28 +0000)
committercorinna <corinna>
Tue, 9 May 2000 13:28:11 +0000 (13:28 +0000)
        in tv_sec.

winsup/cygwin/ChangeLog
winsup/cygwin/window.cc

index 3274a88..de3429b 100644 (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>
 
        Patch suggested by Eric Fifer <EFifer@sanwaint.com>
index 1610574..6651ddc 100644 (file)
@@ -13,6 +13,7 @@ details. */
 #include <sys/time.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <limits.h>
 #include "winsup.h"
 
 static NO_COPY UINT timer_active = 0;
@@ -154,6 +155,12 @@ setitimer (int which, const struct itimerval *value, struct itimerval *oldvalue)
       set_errno (EINVAL);
       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)
     {
       KillTimer (gethwnd(), timer_active);