diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-03 22:24:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 22:24:12 +0800 |
commit | a88c18c24efe2b0d91882a48c4dedae9b8269806 (patch) | |
tree | ca7a48f161162d475a1eaf0e1dda5928f8285bcb /src | |
parent | ef52592cf8bc158a91b276017d1d2e68a620e7e0 (diff) | |
download | rneovim-a88c18c24efe2b0d91882a48c4dedae9b8269806.tar.gz rneovim-a88c18c24efe2b0d91882a48c4dedae9b8269806.tar.bz2 rneovim-a88c18c24efe2b0d91882a48c4dedae9b8269806.zip |
vim-patch:9.0.0527: long sign text may overflow buffer (#22496)
Problem: Long sign text may overflow buffer.
Solution: Use a larger buffer. Prevent for overflow.
https://github.com/vim/vim/commit/2b1ddf19f8f14365d0b998b4ac12ca85c0923475
Don't change the size of extra[] as it's already large enough.
N/A patches for version.c:
vim-patch:9.0.0523: more compiler warnings for arguments in small version
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/drawline.c | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_signs.vim | 14 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index dbbeabbba2..a2ae828f7e 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -413,13 +413,13 @@ static void get_sign_display_info(bool nrcol, win_T *wp, winlinevars_T *wlv, int wlv->c_final = NUL; if (nrcol) { - int n, width = number_width(wp) - 2; - for (n = 0; n < width; n++) { + int width = number_width(wp) - 2; + size_t n; + for (n = 0; (int)n < width; n++) { wlv->extra[n] = ' '; } wlv->extra[n] = NUL; - STRCAT(wlv->extra, wlv->p_extra); - STRCAT(wlv->extra, " "); + snprintf(wlv->extra + n, sizeof(wlv->extra) - n, "%s ", wlv->p_extra); wlv->p_extra = wlv->extra; wlv->n_extra = (int)strlen(wlv->p_extra); } else { diff --git a/src/nvim/testdir/test_signs.vim b/src/nvim/testdir/test_signs.vim index 8311955a15..129f1c1a0c 100644 --- a/src/nvim/testdir/test_signs.vim +++ b/src/nvim/testdir/test_signs.vim @@ -196,6 +196,20 @@ func Test_sign() \ bufnr('%'), 'E155:') 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. " Quoting :help sign " |