neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 69a9a25fccd3e59f604888e2d9c29a822e14cca9
parent 43f7434bd5fa5d13a3aefe4bfaea2973bae7dda2
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu,  2 Oct 2025 07:50:00 +0800

vim-patch:9.1.0689: [security]: buffer-overflow in do_search() with 'rightleft'

Problem:  buffer-overflow in do_search() with 'rightleft'
          (SuyueGuo)
Solution: after reversing the text (which allocates a new buffer),
          re-calculate the text length

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-v2x2-cjcg-f9jm

https://github.com/vim/vim/commit/cacb6693c10bb19f28a50eca47bc4bc33eccbae3

Add missing change from patch 8.1.1270.
Omit `call delete('Untitled')`: moved again in patch 9.1.0695.

Co-authored-by: Christian Brabandt <cb@256bit.org>

Diffstat:
Msrc/nvim/search.c | 3++-
Atest/old/testdir/crash/reverse_text_overflow | 0
Mtest/old/testdir/test_crash.vim | 8++++++++
3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/nvim/search.c b/src/nvim/search.c @@ -1282,9 +1282,10 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, size_t patlen // it would be blanked out again very soon. Show it on the // left, but do reverse the text. if (curwin->w_p_rl && *curwin->w_p_rlc == 's') { - char *r = reverse_text(trunc != NULL ? trunc : msgbuf); + char *r = reverse_text(msgbuf); xfree(msgbuf); msgbuf = r; + msgbuflen = strlen(msgbuf); // move reversed text to beginning of buffer while (*r == ' ') { r++; diff --git a/test/old/testdir/crash/reverse_text_overflow b/test/old/testdir/crash/reverse_text_overflow Binary files differ. diff --git a/test/old/testdir/test_crash.vim b/test/old/testdir/test_crash.vim @@ -150,6 +150,13 @@ func Test_crash1_2() \ ' ; echo "crash 4: [OK]" >> '.. result .. "\<cr>") call TermWait(buf, 150) + let file = 'crash/reverse_text_overflow' + let cmn_args = "%s -u NONE -i NONE -n -X -m -n -e -s -S %s -c ':qa!'" + let args = printf(cmn_args, vim, file) + call term_sendkeys(buf, args .. + \ ' ; echo "crash 5: [OK]" >> '.. result .. "\<cr>") + call TermWait(buf, 150) + " clean up exe buf .. "bw!" exe "sp " .. result @@ -158,6 +165,7 @@ func Test_crash1_2() \ 'crash 2: [OK]', \ 'crash 3: [OK]', \ 'crash 4: [OK]', + \ 'crash 5: [OK]', \ ] call assert_equal(expected, getline(1, '$'))