0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 9.0.0527: long sign text may overflow buffer

Problem:    Long sign text may overflow buffer.
Solution:   Use a larger buffer.  Prevent for overflow.
This commit is contained in:
Bram Moolenaar
2022-09-21 11:21:57 +01:00
parent f7c7aa3594
commit 2b1ddf19f8
3 changed files with 23 additions and 5 deletions

View File

@@ -124,7 +124,9 @@ typedef struct {
int saved_c_final; int saved_c_final;
int saved_char_attr; int saved_char_attr;
char_u extra[21]; // "%ld " and 'fdc' must fit in here char_u extra[NUMBUFLEN + MB_MAXBYTES];
// "%ld " and 'fdc' must fit in here, as well
// any text sign
#ifdef FEAT_DIFF #ifdef FEAT_DIFF
hlf_T diff_hlf; // type of diff highlighting hlf_T diff_hlf; // type of diff highlighting
@@ -259,13 +261,13 @@ get_sign_display_info(
{ {
if (nrcol) if (nrcol)
{ {
int n, width = number_width(wp) - 2; int width = number_width(wp) - 2;
int n;
for (n = 0; n < width; n++) for (n = 0; n < width; n++)
wlv->extra[n] = ' '; wlv->extra[n] = ' ';
wlv->extra[n] = 0; vim_snprintf((char *)wlv->extra + n,
STRCAT(wlv->extra, wlv->p_extra); sizeof(wlv->extra) - n, "%s ", wlv->p_extra);
STRCAT(wlv->extra, " ");
wlv->p_extra = wlv->extra; wlv->p_extra = wlv->extra;
} }
wlv->c_extra = NUL; wlv->c_extra = NUL;

View File

@@ -196,6 +196,20 @@ func Test_sign()
\ bufnr('%'), 'E155:') \ bufnr('%'), 'E155:')
endfunc endfunc
func Test_sign_many_bytes()
new
set signcolumn=number
set number
call setline(1, 'some text')
" composing characters can use many bytes, check for overflow
sign define manyBytes text=᷄᷅᷆᷄᷅᷆᷇
sign place 17 line=1 name=manyBytes
redraw
bwipe!
sign undefine manyBytes
endfunc
" Undefining placed sign is not recommended. " Undefining placed sign is not recommended.
" Quoting :help sign " Quoting :help sign
" "

View File

@@ -699,6 +699,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
527,
/**/ /**/
526, 526,
/**/ /**/