diff options
author | 2015-04-18 18:28:36 +0000 | |
---|---|---|
committer | 2015-04-18 18:28:36 +0000 | |
commit | a47b6461a15f74beac188483616126ed5e987f93 (patch) | |
tree | 4453af12f02f369f89c8895bcfef1820fdb8576d /usr.bin/sed/process.c | |
parent | Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(), (diff) | |
download | wireguard-openbsd-a47b6461a15f74beac188483616126ed5e987f93.tar.xz wireguard-openbsd-a47b6461a15f74beac188483616126ed5e987f93.zip |
Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert
Diffstat (limited to 'usr.bin/sed/process.c')
-rw-r--r-- | usr.bin/sed/process.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index 12385b844a4..aa7ea51d0c4 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process.c,v 1.22 2015/04/13 05:11:23 deraadt Exp $ */ +/* $OpenBSD: process.c,v 1.23 2015/04/18 18:28:37 deraadt Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -457,12 +457,14 @@ lputs(char *s) static int termwidth = -1; if (termwidth == -1) { + termwidth = 0; if ((p = getenv("COLUMNS"))) - termwidth = atoi(p); - else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 && + termwidth = strtonum(p, 0, INT_MAX, NULL); + if (termwidth == 0 && + ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 && win.ws_col > 0) termwidth = win.ws_col; - else + if (termwidth == 0) termwidth = 60; } |