From 63a7e8cbbbbd60eff3c1c67d0a7ae8b2203cf92f Mon Sep 17 00:00:00 2001 From: keramida Date: Sat, 22 Mar 2003 09:23:29 +0000 Subject: Add error and range checking to strtoul() to avoid ending up with a delay time of ULONG_MAX when -I is passed a non-numeric arg. --- usr.sbin/gstat/gstat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'usr.sbin/gstat') diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c index 6c6c4ad..8242935 100644 --- a/usr.sbin/gstat/gstat.c +++ b/usr.sbin/gstat/gstat.c @@ -75,7 +75,8 @@ main(int argc, char **argv) case 'I': p = NULL; i = strtoul(optarg, &p, 0); - if (p == optarg) { + if (p == optarg || errno == EINVAL || + errno == ERANGE) { errx(1, "Invalid argument to -I"); } else if (!strcmp(p, "s")) i *= 1000000; -- cgit v1.1