0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt 2024-08-22 21:40:14 +02:00
parent 95e90781a4
commit cacb6693c1
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
4 changed files with 12 additions and 0 deletions

View File

@ -1548,6 +1548,7 @@ do_search(
{ {
vim_free(msgbuf); vim_free(msgbuf);
msgbuf = r; msgbuf = r;
msgbuflen = STRLEN(msgbuf);
// move reversed text to beginning of buffer // move reversed text to beginning of buffer
while (*r != NUL && *r == ' ') while (*r != NUL && *r == ' ')
r++; r++;

Binary file not shown.

View File

@ -150,6 +150,13 @@ func Test_crash1_2()
\ ' ; echo "crash 4: [OK]" >> '.. result .. "\<cr>") \ ' ; echo "crash 4: [OK]" >> '.. result .. "\<cr>")
call TermWait(buf, 150) 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 " clean up
exe buf .. "bw!" exe buf .. "bw!"
exe "sp " .. result exe "sp " .. result
@ -158,6 +165,7 @@ func Test_crash1_2()
\ 'crash 2: [OK]', \ 'crash 2: [OK]',
\ 'crash 3: [OK]', \ 'crash 3: [OK]',
\ 'crash 4: [OK]', \ 'crash 4: [OK]',
\ 'crash 5: [OK]',
\ ] \ ]
call assert_equal(expected, getline(1, '$')) call assert_equal(expected, getline(1, '$'))
@ -201,6 +209,7 @@ func Test_crash1_3()
let args = printf(cmn_args, vim, file) let args = printf(cmn_args, vim, file)
call term_sendkeys(buf, args) call term_sendkeys(buf, args)
call TermWait(buf, 150) call TermWait(buf, 150)
call delete('Untitled')
let file = 'crash/nullpointer' let file = 'crash/nullpointer'
let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'\<cr>" let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'\<cr>"

View File

@ -704,6 +704,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 */
/**/
689,
/**/ /**/
688, 688,
/**/ /**/