diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-11-19 17:48:53 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-11-19 17:48:53 +0000 |
commit | 90bad3ac908fd8b93e5ccfb6992df2332776919f (patch) | |
tree | 1d6adc4f231074e91d4237452ac16658348895d1 /lib/libocurses | |
parent | 5bba7674f3b9bc8f06cac073e0d2890314468802 (diff) |
ignore out-of-range environment LINES and COLUMNS
Diffstat (limited to 'lib/libocurses')
-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. |