1 Star 0 Fork 52

willwolf/vim

forked from src-openEuler/vim 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-CVE-2022-3591.patch 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
From 8f3c3c6cd044e3b5bf08dbfa3b3f04bb3f711bad Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Tue, 18 Oct 2022 17:05:54 +0100
Subject: [PATCH] patch 9.0.0789: dummy buffer ends up in a window
Problem: Dummy buffer ends up in a window.
Solution: Disallow navigating to a dummy buffer.
---
src/buffer.c | 7 +++++++
src/testdir/test_autocmd.vim | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/src/buffer.c b/src/buffer.c
index 0849b7099..5a4825feb 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1332,6 +1332,13 @@ do_buffer_ext(
)
return OK;
#endif
+ if ((action == DOBUF_GOTO || action == DOBUF_SPLIT)
+ && (buf->b_flags & BF_DUMMY))
+ {
+ // disallow navigating to the dummy buffer
+ semsg(_(e_buffer_nr_does_not_exist), count);
+ return FAIL;
+ }
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 0706e7307..6ba1b02df 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -3857,4 +3857,24 @@ func Test_autocmd_delete()
call assert_true(autocmd_delete([test_null_dict()]))
endfunc
+func Test_autocmd_split_dummy()
+ " Autocommand trying to split a window containing a dummy buffer.
+ auto BufReadPre * exe "sbuf " .. expand("<abuf>")
+ " Avoid the "W11" prompt
+ au FileChangedShell * let v:fcs_choice = 'reload'
+ func Xautocmd_changelist()
+ cal writefile(['Xtestfile2:4:4'], 'Xerr')
+ edit Xerr
+ lex 'Xtestfile2:4:4'
+ endfunc
+ call Xautocmd_changelist()
+ call assert_fails('call Xautocmd_changelist()', 'E86:')
+
+ au! BufReadPre
+ au! FileChangedShell
+ delfunc Xautocmd_changelist
+ bwipe! Xerr
+ call delete('Xerr')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/willwolf/vim.git
git@gitee.com:willwolf/vim.git
willwolf
vim
vim
master

搜索帮助