replace some calls to atoi with strtonum so that netstat -w 0 doesn't
do weird stuff.

Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/main.c,v
retrieving revision 1.99
diff -u -p -r1.99 main.c
--- main.c      10 Jan 2014 04:54:35 -0000      1.99
+++ main.c      13 Feb 2014 16:13:38 -0000
@@ -182,6 +182,8 @@ main(int argc, char *argv[])
                        break;
                case 'c':
                        repeatcount = strtonum(optarg, 1, INT_MAX, &errstr);
+                       if (errstr)
+                               errx(1, "count is %s", errstr);
                        break;
                case 'd':
                        dflag = 1;
@@ -289,7 +291,9 @@ main(int argc, char *argv[])
                        interface = optarg;
                        break;
                case 'w':
-                       interval = atoi(optarg);
+                       interval = strtonum(optarg, 1, INT_MAX, &errstr);
+                       if (errstr)
+                               errx(1, "interval is %s", errstr);
                        iflag = 1;
                        break;
                case '?':
@@ -314,9 +318,9 @@ main(int argc, char *argv[])
 #ifdef BACKWARD_COMPATIBILITY
        if (*argv) {
                if (isdigit((unsigned char)**argv)) {
-                       interval = atoi(*argv);
-                       if (interval <= 0)
-                               usage();
+                       interval = strtonum(*argv, 1, INT_MAX, &errstr);
+                       if (errstr)
+                               errx(1, "interval is %s", errstr);
                        ++argv;
                        iflag = 1;
                }

Reply via email to