xargs: error out if argument to -L is no valid number
authorSimon Schubert <corecode@dragonflybsd.org>
Thu, 20 Aug 2009 00:40:30 +0000 (02:40 +0200)
committerSimon Schubert <corecode@dragonflybsd.org>
Thu, 20 Aug 2009 08:56:36 +0000 (10:56 +0200)
usr.bin/xargs/xargs.c

index 177b8cd..f48b975 100644 (file)
@@ -79,6 +79,7 @@ extern char **environ;
 int
 main(int argc, char *argv[])
 {
+       char *tmp;
        long arg_max;
        int ch, Jflag, nargs, nflag, nline;
        size_t linelen;
@@ -128,7 +129,9 @@ main(int argc, char *argv[])
                        replstr = optarg;
                        break;
                case 'L':
-                       Lflag = atoi(optarg);
+                       Lflag = strtol(optarg, &tmp, 10);
+                       if (*tmp != 0 || *optarg == 0)
+                               errx(1, "illegal argument count");
                        break;
                case 'n':
                        nflag = 1;