To: vim_dev@googlegroups.com Subject: Patch 8.2.3915 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3915 Problem: illegal memory access when completing with invalid bytes. Solution: Avoid going over the end of the completion text. Files: src/insexpand.c, src/testdir/test_ins_complete.vim *** ../vim-8.2.3914/src/insexpand.c 2021-12-27 12:52:03.460567722 +0000 --- src/insexpand.c 2021-12-27 19:26:42.133598773 +0000 *************** *** 3437,3443 **** void ins_compl_insert(int in_compl_func) { ! ins_bytes(compl_shown_match->cp_str + ins_compl_len()); if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) compl_used_match = FALSE; else --- 3437,3448 ---- void ins_compl_insert(int in_compl_func) { ! int compl_len = ins_compl_len(); ! ! // Make sure we don't go over the end of the string, this can happen with ! // illegal bytes. ! if (compl_len < (int)STRLEN(compl_shown_match->cp_str)) ! ins_bytes(compl_shown_match->cp_str + compl_len); if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) compl_used_match = FALSE; else *** ../vim-8.2.3914/src/testdir/test_ins_complete.vim 2021-12-17 16:21:14.911650274 +0000 --- src/testdir/test_ins_complete.vim 2021-12-27 19:25:49.077684001 +0000 *************** *** 103,108 **** --- 103,121 ---- call delete('Xdir', 'rf') endfunc + func Test_ins_complete_invalid_byte() + if has('unix') && executable('base64') + " this weird command was causing an illegal memory access + call writefile(['bm9ybTlvMDCAMM4Dbw4OGA4ODg=='], 'Xinvalid64') + call system('base64 -d Xinvalid64 > Xinvalid') + call writefile(['qa!'], 'Xexit') + call RunVim([], [], " -i NONE -n -X -Z -e -m -s -S Xinvalid -S Xexit") + call delete('Xinvalid64') + call delete('Xinvalid') + call delete('Xexit') + endif + endfunc + func Test_omni_dash() func Omni(findstart, base) if a:findstart *** ../vim-8.2.3914/src/version.c 2021-12-27 17:21:38.024449102 +0000 --- src/version.c 2021-12-27 18:44:30.761552320 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3915, /**/ -- hundred-and-one symptoms of being an internet addict: 122. You ask if the Netaholics Anonymous t-shirt you ordered can be sent to you via e-mail. /// 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 ///