1 Star 0 Fork 58

YukariChiba/vim

forked from src-openEuler/vim 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-CVE-2021-4192.patch 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
renmingshuai 提交于 2022-01-17 17:38 +08:00 . fix CVE-2021-4166 CVE-2021-4192 CVE-2021-4193
From 4c13e5e6763c6eb36a343a2b8235ea227202e952 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Thu, 30 Dec 2021 14:49:43 +0000
Subject: [PATCH] patch 8.2.3949: using freed memory with /\%V
Conflict:NA
Reference:https://github.com/vim/vim/commit/4c13e5e6763c6eb36a343a2b8235ea227202e952
Problem: Using freed memory with /\%V.
Solution: Get the line again after getvvcol().
---
src/regexp.c | 9 +++++++--
src/testdir/test_regexp_latin.vim | 8 ++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/regexp.c b/src/regexp.c
index 2e94e5a..6849cba 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -1276,9 +1276,9 @@ reg_match_visual(void)
if (lnum < top.lnum || lnum > bot.lnum)
return FALSE;
+ col = (colnr_T)(rex.input - rex.line);
if (mode == 'v')
{
- col = (colnr_T)(rex.input - rex.line);
if ((lnum == top.lnum && col < top.col)
|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))
return FALSE;
@@ -1293,7 +1293,12 @@ reg_match_visual(void)
end = end2;
if (top.col == MAXCOL || bot.col == MAXCOL)
end = MAXCOL;
- cols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line));
+
+ // getvvcol() flushes rex.line, need to get it again
+ rex.line = reg_getline(rex.lnum);
+ rex.input = rex.line + col;
+
+ cols = win_linetabsize(wp, rex.line, col);
if (cols < start || cols > end - (*p_sel == 'e'))
return FALSE;
}
diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim
index 3168edc..044b678 100644
--- a/src/testdir/test_regexp_latin.vim
+++ b/src/testdir/test_regexp_latin.vim
@@ -39,6 +39,14 @@ func Test_recursive_substitute()
bwipe!
endfunc
+func Test_using_visual_position()
+ " this was using freed memory
+ new
+ exe "norm 0o\<Esc>\<C-V>k\<C-X>o0"
+ /\%V
+ bwipe!
+endfunc
+
func Test_nested_backrefs()
" Check example in change.txt.
new
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/YukariChiba/vim.git
git@gitee.com:YukariChiba/vim.git
YukariChiba
vim
vim
master

搜索帮助