Patch 8.2.4218

10 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 25, 2022, 3:45:55 PM1/25/22
to vim...@googlegroups.com

Patch 8.2.4218
Problem: Illegal memory access with bracketed paste in Ex mode.
Solution: Reserve space for the trailing NUL.
Files: src/edit.c, src/testdir/test_paste.vim


*** ../vim-8.2.4217/src/edit.c 2022-01-24 15:27:47.179058453 +0000
--- src/edit.c 2022-01-25 20:42:39.737152799 +0000
***************
*** 4452,4458 ****
break;

case PASTE_EX:
! if (gap != NULL && ga_grow(gap, idx) == OK)
{
mch_memmove((char *)gap->ga_data + gap->ga_len,
buf, (size_t)idx);
--- 4452,4459 ----
break;

case PASTE_EX:
! // add one for the NUL that is going to be appended
! if (gap != NULL && ga_grow(gap, idx + 1) == OK)
{
mch_memmove((char *)gap->ga_data + gap->ga_len,
buf, (size_t)idx);
*** ../vim-8.2.4217/src/testdir/test_paste.vim 2021-10-16 13:00:10.936165341 +0100
--- src/testdir/test_paste.vim 2022-01-25 20:41:48.286093667 +0000
***************
*** 90,95 ****
--- 90,98 ----
unlet! foo
call feedkeys("Qlet foo=\"\<Esc>[200~foo\<CR>bar\<Esc>[201~\"\<CR>vi\<CR>", 'xt')
call assert_equal("foo\rbar", foo)
+
+ " pasting more than 40 bytes
+ exe "norm Q\<PasteStart>0000000000000000000000000000000000000000000000000000000000000000000000\<C-C>"
endfunc

func Test_paste_onechar()
*** ../vim-8.2.4217/src/version.c 2022-01-25 18:23:57.102514548 +0000
--- src/version.c 2022-01-25 20:27:48.340762717 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4218,
/**/

--
Beer & pretzels can't be served at the same time in any bar or restaurant.
[real standing law in North Dakota, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages