2 Star 0 Fork 53

openMajun/vim

forked from src-openEuler/vim 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-CVE-2022-0685.patch 2.42 KB
一键复制 编辑 原始数据 按行查看 历史
桐小哥 提交于 2022-03-09 17:40 . fix CVE-2022-0685
From 5921aeb5741fc6e84c870d68c7c35b93ad0c9f87 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Sat, 19 Feb 2022 11:20:12 +0000
Subject: [PATCH] patch 8.2.4418: crash when using special multi-byte character
Problem: Crash when using special multi-byte character.
Solution: Don't use isalpha() for an arbitrary character.
Conflict:
upstream patches:
+ call assert_fails('tc űŤŤŤ¦*', 'E344:')
openEuler patches:
+ call assert_fails('tc űŤŤŤ¦*', 'E472:')
---
src/charset.c | 6 ++++++
src/filepath.c | 2 +-
src/proto/charset.pro | 2 +-
src/testdir/test_autochdir.vim | 7 +++++++
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/charset.c b/src/charset.c
index a768c17..847a01a 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1654,6 +1654,12 @@ vim_isupper(int c)
return isupper(c);
}
+ int
+vim_isalpha(int c)
+{
+ return vim_islower(c) || vim_isupper(c);
+}
+
int
vim_toupper(int c)
{
diff --git a/src/filepath.c b/src/filepath.c
index 01d2dcb..c7f0265 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -3300,7 +3300,7 @@ unix_expandpath(
else if (path_end >= path + wildoff
&& (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL
|| (!p_fic && (flags & EW_ICASE)
- && isalpha(PTR2CHAR(path_end)))))
+ && vim_isalpha(PTR2CHAR(path_end)))))
e = p;
if (has_mbyte)
{
diff --git a/src/proto/charset.pro b/src/proto/charset.pro
index c582a8c..2a928e3 100644
--- a/src/proto/charset.pro
+++ b/src/proto/charset.pro
@@ -47,6 +47,7 @@ int vim_isxdigit(int c);
int vim_isbdigit(int c);
int vim_islower(int c);
int vim_isupper(int c);
+int vim_isalpha(int c);
int vim_toupper(int c);
int vim_tolower(int c);
char_u *skiptowhite(char_u *p);
@@ -59,5 +60,4 @@ int hexhex2nr(char_u *p);
int rem_backslash(char_u *str);
void backslash_halve(char_u *p);
char_u *backslash_halve_save(char_u *p);
-void ebcdic2ascii(char_u *buffer, int len);
/* vim: set ft=c : */
diff --git a/src/testdir/test_autochdir.vim b/src/testdir/test_autochdir.vim
index 1473854..99fc9ae 100644
--- a/src/testdir/test_autochdir.vim
+++ b/src/testdir/test_autochdir.vim
@@ -24,3 +24,10 @@ func Test_set_filename()
call chdir(cwd)
call delete('samples/Xtest')
endfunc
+
+func Test_multibyte()
+ " using an invalid character should not cause a crash
+ set wic
+ call assert_fails('tc űŤŤŤ¦*', 'E472:')
+ set nowic
+endfunc
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openMajun/vim.git
git@gitee.com:openMajun/vim.git
openMajun
vim
vim
master

搜索帮助