fix CVE-2022-0213

(cherry picked from commit 57c2d8ba6985ae8f7790b5c0c01995e25e157a07)
This commit is contained in:
guozhaorui 2022-01-20 20:35:35 +08:00 committed by openeuler-sync-bot
parent e80197122a
commit 7b15bf7ff2
2 changed files with 70 additions and 1 deletions

View File

@ -0,0 +1,62 @@
From de05bb25733c3319e18dca44e9b59c6ee389eb26 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Thu, 13 Jan 2022 13:08:14 +0000
Subject: [PATCH] patch 8.2.4074: going over the end of NameBuff
Problem: Going over the end of NameBuff.
Solution: Check length when appending a space.
---
src/drawscreen.c | 9 +++++----
src/testdir/test_edit.vim | 15 +++++++++++++++
src/version.c | 2 ++
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 9acb705..7425ad4 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -437,12 +437,13 @@ win_redr_status(win_T *wp, int ignore_pum UNUSED)
p = NameBuff;
len = (int)STRLEN(p);
- if (bt_help(wp->w_buffer)
+ if ((bt_help(wp->w_buffer)
#ifdef FEAT_QUICKFIX
- || wp->w_p_pvw
+ || wp->w_p_pvw
#endif
- || bufIsChanged(wp->w_buffer)
- || wp->w_buffer->b_p_ro)
+ || bufIsChanged(wp->w_buffer)
+ || wp->w_buffer->b_p_ro)
+ && len < MAXPATHL - 1)
*(p + len++) = ' ';
if (bt_help(wp->w_buffer))
{
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index c3b1af5..48e6ff2 100644
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -1532,3 +1532,18 @@ func Test_edit_put_CTRL_E()
set encoding=utf-8
endfunc
+" Weird long file name was going over the end of NameBuff
+func Test_edit_overlong_file_name()
+ CheckUnix
+
+ file 0000000000000000000000000000
+ file %%%%%%%%%%%%%%%%%%%%%%%%%%
+ file %%%%%%
+ set readonly
+ set ls=2
+
+ redraw!
+ set noreadonly ls&
+ bwipe!
+endfunc
+
--
2.23.0

View File

@ -11,7 +11,7 @@
Name: vim
Epoch: 2
Version: 8.2
Release: 11
Release: 12
Summary: Vim is a highly configurable text editor for efficiently creating and changing any kind of text.
License: Vim and MIT
URL: http://www.vim.org
@ -54,6 +54,7 @@ Patch6020: backport-CVE-2021-4166.patch
Patch6021: backport-fix-arglist-test-fails.patch
Patch6022: backport-CVE-2021-4192.patch
Patch6023: backport-CVE-2021-4193.patch
Patch6024: backport-CVE-2022-0213.patch
Patch9000: bugfix-rm-modify-info-version.patch
@ -442,6 +443,12 @@ popd
%{_mandir}/man1/evim.*
%changelog
* Thu Jan 20 2022 guozhaorui<guozhaorui1@huawei.com> - 2:8.2-12
- Type:CVE
- ID:CVE-2022-0213
- SUG:NA
- DESC:fix CVE-2022-0213
* Mon Jan 17 2022 yuanxin<yuanxin24@huawei.com> - 2:8.2-11
- Type:CVE
- ID:CVE-2021-4166 CVE-2021-4192 CVE-2021-4193