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 <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen authored and Lukas Fleischer committed 2017-08-12 15:40:02 +02:00
1 parent 53db74ab34
commit b36dd2e614
1 file changed
+2
+2
View File
@@ -135,6 +135,7 @@ void fatalbox(const char *errmsg)
return; return;
strncpy(msg, errmsg, MSGLEN); strncpy(msg, errmsg, MSGLEN);
msg[MSGLEN - 1] = '\0';
errwin = errwin =
newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
custom_apply_attr(errwin, ATTR_HIGHEST); custom_apply_attr(errwin, ATTR_HIGHEST);
@@ -162,6 +163,7 @@ void warnbox(const char *msg)
return; return;
strncpy(displmsg, msg, MSGLEN); strncpy(displmsg, msg, MSGLEN);
displmsg[MSGLEN - 1] = '\0';
warnwin = warnwin =
newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
custom_apply_attr(warnwin, ATTR_HIGHEST); custom_apply_attr(warnwin, ATTR_HIGHEST);