Hi,

nanosleep(2) won't take more than 100 million seconds at a time,
so we ought to cap interval when we read it in.  Otherwise, an
oversized interval argument causes iostat(8) to print as fast as
it can.

While here, "interval" is called "wait" in the documentation when
the new syntax is in use, so we should call it that in the error
message for the '-w' flag.

ok?

--
Scott Cheloha

Index: usr.sbin/iostat/iostat.c
===================================================================
RCS file: /cvs/src/usr.sbin/iostat/iostat.c,v
retrieving revision 1.39
diff -u -p -r1.39 iostat.c
--- usr.sbin/iostat/iostat.c    23 Oct 2015 08:21:27 -0000      1.39
+++ usr.sbin/iostat/iostat.c    9 Feb 2018 23:39:15 -0000
@@ -146,9 +146,9 @@ main(int argc, char *argv[])
                        todo |= SHOW_TTY;
                        break;
                case 'w':
-                       interval = strtonum(optarg, 1, INT_MAX, &errstr);
+                       interval = strtonum(optarg, 1, 100000000, &errstr);
                        if (errstr)
-                               errx(1, "interval is %s", errstr);
+                               errx(1, "wait is %s", errstr);
                        break;
                case '?':
                default:
@@ -419,7 +419,7 @@ selectdrives(char *argv[])
                        errx(1, "invalid interval or drive name: %s", *argv);
        }
        if (*argv) {
-               interval = strtonum(*argv, 1, INT_MAX, &errstr);
+               interval = strtonum(*argv, 1, 100000000, &errstr);
                if (errstr)
                        errx(1, "interval is %s", errstr);
                if (*++argv) {

Reply via email to