diff options
author | 1998-11-19 17:48:52 +0000 | |
---|---|---|
committer | 1998-11-19 17:48:52 +0000 | |
commit | 9dd6074719f47ce815ff3cb704cca4f428fbecd4 (patch) | |
tree | 13f1d034cfaee8bbdac53a0c35dc49f25ea8d94b /lib/libocurses/setterm.c | |
parent | For issetugid case, only ignore $TERMCAP if it is a path (diff) | |
download | wireguard-openbsd-9dd6074719f47ce815ff3cb704cca4f428fbecd4.tar.xz wireguard-openbsd-9dd6074719f47ce815ff3cb704cca4f428fbecd4.zip |
ignore out-of-range environment LINES and COLUMNS
Diffstat (limited to 'lib/libocurses/setterm.c')
-rw-r--r-- | lib/libocurses/setterm.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libocurses/setterm.c b/lib/libocurses/setterm.c index 1d134903c11..4652edfc596 100644 --- a/lib/libocurses/setterm.c +++ b/lib/libocurses/setterm.c @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)setterm.c 8.7 (Berkeley) 7/27/94"; #include <string.h> #include <termios.h> #include <unistd.h> +#include <limits.h> #include "curses.h" @@ -116,10 +117,16 @@ setterm(type) } /* POSIX 1003.2 requires that the environment override. */ - if ((p = getenv("LINES")) != NULL) - LINES = strtol(p, NULL, 10); - if ((p = getenv("COLUMNS")) != NULL) - COLS = strtol(p, NULL, 10); + if ((p = getenv("LINES")) != NULL) { + long l = strtol(p, &p, 10); + if (l > 0 && l < INT_MAX && *p == '\0') + LINES = (int)l; + } + if ((p = getenv("COLUMNS")) != NULL) { + long l = strtol(p, &p, 10); + if (l > 0 && l < INT_MAX && *p == '\0') + COLS = (int)l; + } /* * Want cols > 4, otherwise things will fail. |