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.
This commit is contained in:
Giorgos Keramidas committed 2003-03-22 09:23:29 +00:00
1 parent 86b81cd948
commit 4fe8c1b67b
1 file changed
+2 -1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112487
+2 -1
View File
@@ -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;