From d4a9781d4ae018408fd1e3a59f257b8ec71bf885 Mon Sep 17 00:00:00 2001 From: albert <> Date: Sat, 17 Jun 2006 04:52:42 +0000 Subject: [PATCH] avoid integer overflow for usleep() arg --- NEWS | 1 + watch.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 65093311..513e673e 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ top: document H option -- thanks Tony Ernst top: terabytes -- thanks Tony Ernst ps: SCHED_BATCH is B ps: fix s format (signals) output with thread display +watch: avoid integer overflow for the time delay procps-3.2.5 --> procps-3.2.6 diff --git a/watch.c b/watch.c index 67f9da1a..7d7be933 100644 --- a/watch.c +++ b/watch.c @@ -141,7 +141,7 @@ main(int argc, char *argv[]) int option_differences = 0, option_differences_cumulative = 0, option_help = 0, option_version = 0; - float interval = 2; + double interval = 2; char *command; int command_length = 0; /* not including final \0 */ @@ -165,11 +165,13 @@ main(int argc, char *argv[]) case 'n': { char *str; - interval = strtof(optarg, &str); + interval = strtod(optarg, &str); if (!*optarg || *str) do_usage(); if(interval < 0.1) interval = 0.1; + if(interval > ~0u/1000000) + interval = ~0u/1000000; } break; case 'v':