From e6e228e7f4ce674a3017dda80ab196022a4046a4 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 19 Feb 2017 15:12:42 +0000 Subject: [PATCH] Fix out of boundary write on 1x1 terminals If a terminal is merely 1x1 in size, setsize() will write a nul byte in front of the allocated memory, which is an out of boundary write. --- tload.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tload.c b/tload.c index 8b9fab33..7160462f 100644 --- a/tload.c +++ b/tload.c @@ -70,6 +70,8 @@ static void setsize(int i) nrows = win.ws_row; } scr_size = nrows * ncols; + if (scr_size < 2) + xerr(EXIT_FAILURE, _("screen too small")); if (screen == NULL) screen = (char *)xmalloc(scr_size); else -- 2.40.0