From: David Lawrence Ramsey Date: Thu, 31 Mar 2005 00:11:43 +0000 (+0000) Subject: in statusq(), make sure that the vsnprintf(foo) call and foo's X-Git-Tag: v1.3.7~18 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=612caef65ff8c3048c5d6c965abdc8fb876095dd;p=nano.git in statusq(), make sure that the vsnprintf(foo) call and foo's subsequent null termination both take the proper number of bytes when using multibyte characters, so that multibyte prompt strings aren't prematurely cut off git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2444 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 0ad374e4..09e4faae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -75,6 +75,11 @@ CVS code - regexec_safe() - Rename to safe_regexec() for consistency. (DLR) - winio.c: + statusq() + - Make sure that the vsnprintf(foo) call and foo's subsequent + null termination both take the proper number of bytes when + using multibyte characters, so that multibyte prompt strings + aren't prematurely cut off. (DLR) titlebar() - Make sure that the (mv)?waddnstr() calls take the proper number of bytes when using multibyte characters, so that diff --git a/src/winio.c b/src/winio.c index 11cc87d1..30e02b4b 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2652,7 +2652,7 @@ int statusq(bool allow_tabs, const shortcut *s, const char *def, const char *msg, ...) { va_list ap; - char *foo = charalloc(COLS - 3); + char *foo = charalloc(((COLS - 4) * mb_cur_max()) + 1); int ret; #ifndef DISABLE_TABCOMP bool list = FALSE; @@ -2661,9 +2661,9 @@ int statusq(bool allow_tabs, const shortcut *s, const char *def, bottombars(s); va_start(ap, msg); - vsnprintf(foo, COLS - 4, msg, ap); + vsnprintf(foo, (COLS - 4) * mb_cur_max(), msg, ap); va_end(ap); - foo[COLS - 4] = '\0'; + null_at(&foo, actual_x(foo, COLS - 4)); ret = nanogetstr(allow_tabs, foo, def, #ifndef NANO_SMALL