--F.

Index: ps.c
===================================================================
RCS file: /cvs/src/bin/ps/ps.c,v
retrieving revision 1.63
diff -u -r1.63 ps.c
--- ps.c        16 Jan 2015 06:39:32 -0000      1.63
+++ ps.c        8 Mar 2016 14:15:34 -0000
@@ -99,6 +99,7 @@
        int all, ch, flag, i, fmt, lineno, nentries;
        int prtheader, showthreads, wflag, kflag, what, Uflag, xflg;
        char *nlistf, *memf, *swapf, *cols, errbuf[_POSIX2_LINE_MAX];
+       const char *errstr;
 
        if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') {
                const char *errstr;
@@ -189,7 +190,9 @@
                        fmt = 1;
                        break;
                case 'p':
-                       pid = atol(optarg);
+                       pid = strtonum(optarg, 1, INT_MAX, &errstr);
+                       if (errstr != NULL)
+                               errx(1, "%s is an invalid pid", optarg);
                        xflg = 1;
                        break;
                case 'r':

Reply via email to