2 Star 0 Fork 54

openMajun/vim

forked from src-openEuler/vim 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-memory-leak-for-retab-with-invalid-argument.patch 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
shixuantong 提交于 2021-09-11 08:08 . fix CVE-2021-3770
From 2ddb89f8a94425cda1e5491efc80c1ccccb6e08e Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Sat, 4 Sep 2021 21:20:41 +0200
Subject: [PATCH] patch 8.2.3403: memory leak for :retab with invalid argument
Problem: Memory leak for :retab with invalid argument.
Solution: Free the memory. Make error messages consistent.
---
src/indent.c | 13 +++++++++++--
src/version.c | 2 ++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/indent.c b/src/indent.c
index 7e196c2..7d04373 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -70,9 +70,12 @@ tabstop_set(char_u *var, int **array)
{
int n = atoi((char *)cp);
+ // Catch negative values, overflow and ridiculous big values.
if (n < 0 || n > 9999)
{
semsg(_(e_invarg2), cp);
+ vim_free(*array);
+ *array = NULL;
return FAIL;
}
(*array)[t++] = n;
@@ -1580,12 +1583,18 @@ ex_retab(exarg_T *eap)
else
new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
#else
- new_ts = getdigits(&(eap->arg));
- if (new_ts < 0)
+ ptr = eap->arg;
+ new_ts = getdigits(&ptr);
+ if (new_ts < 0 && *eap->arg == '-')
{
emsg(_(e_positive));
return;
}
+ if (new_ts < 0 || new_ts > 9999)
+ {
+ semsg(_(e_invarg2), eap->arg);
+ return;
+ }
if (new_ts == 0)
new_ts = curbuf->b_p_ts;
#endif
diff --git a/src/version.c b/src/version.c
index 8912f62..f8e4561 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3403,
+/**/
3402,
/**/
0
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openMajun/vim.git
git@gitee.com:openMajun/vim.git
openMajun
vim
vim
master

搜索帮助