aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiorgos Keramidas <keramida@FreeBSD.org>2003-03-22 09:23:29 +0000
committerGiorgos Keramidas <keramida@FreeBSD.org>2003-03-22 09:23:29 +0000
commit4fe8c1b67be0f8f7ecdefea1aee93a5f0eb64f88 (patch)
tree89c6aad925db76b2f26623e53e9a7b5a7b485946
parent86b81cd94898f6d59dcaaafa67ebf61f4bd36d12 (diff)
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.
Notes
svn path=/head/; revision=112487
-rw-r--r--usr.sbin/gstat/gstat.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c
index 6c6c4ad20af5..82429353576a 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;