To: vim_dev@googlegroups.com Subject: Patch 8.2.4218 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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=\"\[200~foo\bar\[201~\"\vi\", 'xt') call assert_equal("foo\rbar", foo) + + " pasting more than 40 bytes + exe "norm Q\0000000000000000000000000000000000000000000000000000000000000000000000\" 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 -- Bram@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 ///