summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/terminal-util.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index a667154270..c2aa75c6a8 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -819,11 +819,11 @@ unsigned columns(void) {
if (e)
(void) safe_atoi(e, &c);
- if (c <= 0)
+ if (c <= 0 || c > USHRT_MAX) {
c = fd_columns(STDOUT_FILENO);
-
- if (c <= 0)
- c = 80;
+ if (c <= 0)
+ c = 80;
+ }
cached_columns = c;
return cached_columns;
@@ -853,11 +853,11 @@ unsigned lines(void) {
if (e)
(void) safe_atoi(e, &l);
- if (l <= 0)
+ if (l <= 0 || l > USHRT_MAX) {
l = fd_lines(STDOUT_FILENO);
-
- if (l <= 0)
- l = 24;
+ if (l <= 0)
+ l = 24;
+ }
cached_lines = l;
return cached_lines;