summaryrefslogtreecommitdiff
path: root/usr.bin/column
diff options
context:
space:
mode:
authorJason Dixon <jdixon@cvs.openbsd.org>2007-05-01 01:26:31 +0000
committerJason Dixon <jdixon@cvs.openbsd.org>2007-05-01 01:26:31 +0000
commit590163d65312d46ce50fbc60b432282034b60d53 (patch)
tree2fbc429ee3707485fcb25104b991b5bb31d39ec2 /usr.bin/column
parent99beccf5f8090559ad8dfc7fbbd1161bdadf4c1a (diff)
use strtonum; ok millert@
Diffstat (limited to 'usr.bin/column')
-rw-r--r--usr.bin/column/column.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c
index 5a3b17ff7d4..df951bd9946 100644
--- a/usr.bin/column/column.c
+++ b/usr.bin/column/column.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: column.c,v 1.12 2007/03/20 03:50:39 tedu Exp $ */
+/* $OpenBSD: column.c,v 1.13 2007/05/01 01:26:23 jdixon Exp $ */
/* $NetBSD: column.c,v 1.4 1995/09/02 05:53:03 jtc Exp $ */
/*
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95";
#endif
-static char rcsid[] = "$OpenBSD: column.c,v 1.12 2007/03/20 03:50:39 tedu Exp $";
+static char rcsid[] = "$OpenBSD: column.c,v 1.13 2007/05/01 01:26:23 jdixon Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -77,10 +77,14 @@ main(int argc, char *argv[])
FILE *fp;
int ch, tflag, xflag;
char *p;
+ const char *errstr;
if (ioctl(1, TIOCGWINSZ, &win) == -1 || !win.ws_col) {
- if ((p = getenv("COLUMNS")))
- termwidth = atoi(p);
+ if ((p = getenv("COLUMNS")) && *p != '\0') {
+ termwidth = strtonum(p, 1, INT_MAX, &errstr);
+ if (errstr != NULL)
+ errx(1, "%s: %s", errstr, p);
+ }
} else
termwidth = win.ws_col;
@@ -88,7 +92,9 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "c:s:tx")) != -1)
switch(ch) {
case 'c':
- termwidth = atoi(optarg);
+ termwidth = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr != NULL)
+ errx(1, "%s: %s", errstr, optarg);
break;
case 's':
separator = optarg;