diff options
author | imp <imp@FreeBSD.org> | 1999-01-06 08:25:56 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 1999-01-06 08:25:56 +0000 |
commit | 64f85516ac74006dd43e3c212ef0c363671d3adb (patch) | |
tree | 4fb0e3285005180972b912a59d90ab70caebc82b | |
parent | 4695982235738320dd9801a117ce0e700b0b2fdf (diff) | |
download | FreeBSD-src-64f85516ac74006dd43e3c212ef0c363671d3adb.zip FreeBSD-src-64f85516ac74006dd43e3c212ef0c363671d3adb.tar.gz |
Add sanity checking to argument for -# and -i. Require these
arguments to be numbers. Also use '0' base to allow hex, octal or
decimal numbers.
This was done by me based on ideas in pr 3556, submitted by Uwe
Laubenstein and commented upon by j@uriah.heep.sax.de (J Wunsch).
PR: 3556
-rw-r--r-- | usr.sbin/lpr/lpr/lpr.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c index 54131ad..b36e40d 100644 --- a/usr.sbin/lpr/lpr/lpr.c +++ b/usr.sbin/lpr/lpr/lpr.c @@ -48,7 +48,7 @@ static const char copyright[] = static char sccsid[] = "@(#)from: lpr.c 8.4 (Berkeley) 4/28/95"; #endif static const char rcsid[] = - "$Id: lpr.c,v 1.24 1998/04/17 17:25:49 obrien Exp $"; + "$Id: lpr.c,v 1.25 1998/09/11 18:49:33 wollman Exp $"; #endif /* not lint */ /* @@ -126,7 +126,7 @@ main(argc, argv) { struct passwd *pw; struct group *gptr; - char *arg, *cp, *printer; + char *arg, *cp, *printer, *p; char buf[BUFSIZ]; int c, i, f, errs; struct stat stb; @@ -154,7 +154,9 @@ main(argc, argv) ":#:1:2:3:4:C:J:P:T:U:cdfghi:lnmprstvw:")) != -1) switch (c) { case '#': /* n copies */ - i = atoi(optarg); + i = strtol(optarg, &p, 0); + if (*p) + errx(1, "Bad argument to -#, number expected"); if (i > 0) ncopies = i; break; @@ -210,7 +212,9 @@ main(argc, argv) case 'i': /* indent output */ iflag++; - indent = atoi(optarg); + indent = strtol(optarg, &p, 0); + if (*p) + errx(1, "Bad argument to -i, number expected"); break; case 'm': /* send mail when done */ |