vim/backport-CVE-2022-1851.patch
weiwei_tiantian 9f42cd6722 fix CVE-2022-1851
(cherry picked from commit 18adec6ac00fb4126d9275c7313955a4b0c94d61)
2022-06-20 14:23:09 +08:00

55 lines
1.5 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 78d52883e10d71f23ab72a3d8b9733b00da8c9ad Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Tue, 24 May 2022 13:57:54 +0100
Subject: [PATCH] patch 8.2.5013: after text formatting cursor may be in an
invalid position
Problem: After text formatting the cursor may be in an invalid position.
Solution: Correct the cursor position after formatting.
Reference:https://github.com/vim/vim/commit/78d52883e10d71f23ab72a3d8b9733b00da8c9ad
Conflict: delete src/version.c and change src/ops.c file
---
src/ops.c | 3 +++
src/testdir/test_textformat.vim | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/src/ops.c b/src/ops.c
index a79ef92..2a64db0 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -2296,6 +2296,9 @@ op_format(
{
curwin->w_cursor = saved_cursor;
saved_cursor.lnum = 0;
+
+ // formatting may have made the cursor position invalid
+ check_cursor();
}
if (oap->is_VIsual)
diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim
index 3a0552b..5e1d335 100644
--- a/src/testdir/test_textformat.vim
+++ b/src/testdir/test_textformat.vim
@@ -509,3 +509,15 @@ func Test_crash_github_issue_5095()
augroup END
augroup! testing
endfunc
+
+" This was leaving the cursor after the end of a line. Complicated way to
+" have the problem show up with valgrind.
+func Test_correct_cursor_position()
+ set encoding=iso8859
+ new
+ norm a000“0
+ sil! norm gggg0i0gw0gg
+
+ bwipe!
+ set encoding=utf8
+endfunc
--
2.27.0