mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Problem: [security]: Heap buffer overflow when calling complete_add()
in the first call of 'completefunc'
Solution: Call check_cursor() after calling 'completefunc' (zeertzjq)
closes: vim/vim#14391
0a419e07a7
This commit is contained in:
@@ -2436,6 +2436,7 @@ static void expand_by_function(int type, char *base)
|
|||||||
textlock--;
|
textlock--;
|
||||||
|
|
||||||
curwin->w_cursor = pos; // restore the cursor position
|
curwin->w_cursor = pos; // restore the cursor position
|
||||||
|
check_cursor(curwin); // make sure cursor position is valid, just in case
|
||||||
validate_cursor(curwin);
|
validate_cursor(curwin);
|
||||||
if (!equalpos(curwin->w_cursor, pos)) {
|
if (!equalpos(curwin->w_cursor, pos)) {
|
||||||
emsg(_(e_compldel));
|
emsg(_(e_compldel));
|
||||||
@@ -4059,6 +4060,7 @@ static int get_userdefined_compl_info(colnr_T curs_col)
|
|||||||
|
|
||||||
State = save_State;
|
State = save_State;
|
||||||
curwin->w_cursor = pos; // restore the cursor position
|
curwin->w_cursor = pos; // restore the cursor position
|
||||||
|
check_cursor(curwin); // make sure cursor position is valid, just in case
|
||||||
validate_cursor(curwin);
|
validate_cursor(curwin);
|
||||||
if (!equalpos(curwin->w_cursor, pos)) {
|
if (!equalpos(curwin->w_cursor, pos)) {
|
||||||
emsg(_(e_compldel));
|
emsg(_(e_compldel));
|
||||||
|
@@ -2490,4 +2490,26 @@ func Test_complete_changed_complete_info()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_completefunc_first_call_complete_add()
|
||||||
|
new
|
||||||
|
|
||||||
|
func Complete(findstart, base) abort
|
||||||
|
if a:findstart
|
||||||
|
let col = col('.')
|
||||||
|
call complete_add('#')
|
||||||
|
return col - 1
|
||||||
|
else
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
set completeopt=longest completefunc=Complete
|
||||||
|
" This used to cause heap-buffer-overflow
|
||||||
|
call assert_fails('call feedkeys("ifoo#\<C-X>\<C-U>", "xt")', 'E840:')
|
||||||
|
|
||||||
|
delfunc Complete
|
||||||
|
set completeopt& completefunc&
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
||||||
|
Reference in New Issue
Block a user