Skip to content

Commit cacb669

Browse files
committed
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: GHSA-v2x2-cjcg-f9jm Signed-off-by: Christian Brabandt <[email protected]>
1 parent 95e9078 commit cacb669

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/search.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,7 @@ do_search(
15481548
{
15491549
vim_free(msgbuf);
15501550
msgbuf = r;
1551+
msgbuflen = STRLEN(msgbuf);
15511552
// move reversed text to beginning of buffer
15521553
while (*r != NUL && *r == ' ')
15531554
r++;
314 Bytes
Binary file not shown.

src/testdir/test_crash.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ func Test_crash1_2()
150150
\ ' ; echo "crash 4: [OK]" >> '.. result .. "\<cr>")
151151
call TermWait(buf, 150)
152152

153+
let file = 'crash/reverse_text_overflow'
154+
let cmn_args = "%s -u NONE -i NONE -n -X -m -n -e -s -S %s -c ':qa!'"
155+
let args = printf(cmn_args, vim, file)
156+
call term_sendkeys(buf, args ..
157+
\ ' ; echo "crash 5: [OK]" >> '.. result .. "\<cr>")
158+
call TermWait(buf, 150)
159+
153160
" clean up
154161
exe buf .. "bw!"
155162
exe "sp " .. result
@@ -158,6 +165,7 @@ func Test_crash1_2()
158165
\ 'crash 2: [OK]',
159166
\ 'crash 3: [OK]',
160167
\ 'crash 4: [OK]',
168+
\ 'crash 5: [OK]',
161169
\ ]
162170

163171
call assert_equal(expected, getline(1, '$'))
@@ -201,6 +209,7 @@ func Test_crash1_3()
201209
let args = printf(cmn_args, vim, file)
202210
call term_sendkeys(buf, args)
203211
call TermWait(buf, 150)
212+
call delete('Untitled')
204213

205214
let file = 'crash/nullpointer'
206215
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'\<cr>"

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
689,
707709
/**/
708710
688,
709711
/**/

0 commit comments

Comments
 (0)