From b36dd2e614f51d7061b8dabd0bb139833ef7bed4 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Fri, 11 Aug 2017 10:24:53 +0200 Subject: Fix empty warning box when key is already in use When adding a key already in use for another action, a warning box is displayed. The text length is limited by the window width through the use of strncpy(). If the limit is exceeded, the string will have no null termination, resulting in unpredictable behaviour. A similar problem in fatalbox() is fixed as well. Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/utils.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/utils.c b/src/utils.c index 9d131ad..4719add 100644 --- a/src/utils.c +++ b/src/utils.c @@ -135,6 +135,7 @@ void fatalbox(const char *errmsg) return; strncpy(msg, errmsg, MSGLEN); + msg[MSGLEN - 1] = '\0'; errwin = newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); custom_apply_attr(errwin, ATTR_HIGHEST); @@ -162,6 +163,7 @@ void warnbox(const char *msg) return; strncpy(displmsg, msg, MSGLEN); + displmsg[MSGLEN - 1] = '\0'; warnwin = newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); custom_apply_attr(warnwin, ATTR_HIGHEST); -- cgit v1.2.3-70-g09d2