summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/vim/files/0004-patch-8.2.3489-ml_get-error-after-search-with-range.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-support/vim/files/0004-patch-8.2.3489-ml_get-error-after-search-with-range.patch')
-rw-r--r--meta/recipes-support/vim/files/0004-patch-8.2.3489-ml_get-error-after-search-with-range.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/meta/recipes-support/vim/files/0004-patch-8.2.3489-ml_get-error-after-search-with-range.patch b/meta/recipes-support/vim/files/0004-patch-8.2.3489-ml_get-error-after-search-with-range.patch
new file mode 100644
index 0000000000..045081579c
--- /dev/null
+++ b/meta/recipes-support/vim/files/0004-patch-8.2.3489-ml_get-error-after-search-with-range.patch
@@ -0,0 +1,72 @@
1CVE: CVE-2021-3875
2Upstream-Status: Backport
3Signed-off-by: Ross Burton <ross.burton@arm.com>
4
5From b8968e26d7508e7d64bfc86808142818b0a9288c Mon Sep 17 00:00:00 2001
6From: Bram Moolenaar <Bram@vim.org>
7Date: Sat, 9 Oct 2021 13:58:55 +0100
8Subject: [PATCH] patch 8.2.3489: ml_get error after search with range
9
10Problem: ml_get error after search with range.
11Solution: Limit the line number to the buffer line count.
12---
13 src/ex_docmd.c | 6 ++++--
14 src/testdir/test_search.vim | 17 +++++++++++++++++
15 src/version.c | 2 ++
16 3 files changed, 23 insertions(+), 2 deletions(-)
17
18diff --git a/src/ex_docmd.c b/src/ex_docmd.c
19index fb07450f8..fde726477 100644
20--- a/src/ex_docmd.c
21+++ b/src/ex_docmd.c
22@@ -3586,8 +3586,10 @@ get_address(
23
24 // When '/' or '?' follows another address, start from
25 // there.
26- if (lnum != MAXLNUM)
27- curwin->w_cursor.lnum = lnum;
28+ if (lnum > 0 && lnum != MAXLNUM)
29+ curwin->w_cursor.lnum =
30+ lnum > curbuf->b_ml.ml_line_count
31+ ? curbuf->b_ml.ml_line_count : lnum;
32
33 // Start a forward search at the end of the line (unless
34 // before the first line).
35diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
36index 187671305..e142c3547 100644
37--- a/src/testdir/test_search.vim
38+++ b/src/testdir/test_search.vim
39@@ -1366,3 +1366,20 @@ func Test_searchdecl()
40
41 bwipe!
42 endfunc
43+
44+func Test_search_with_invalid_range()
45+ new
46+ let lines =<< trim END
47+ /\%.v
48+ 5/
49+ c
50+ END
51+ call writefile(lines, 'Xrangesearch')
52+ source Xrangesearch
53+
54+ bwipe!
55+ call delete('Xrangesearch')
56+endfunc
57+
58+
59+" vim: shiftwidth=2 sts=2 expandtab
60diff --git a/src/version.c b/src/version.c
61index 2b5de5ccf..092864bbb 100644
62--- a/src/version.c
63+++ b/src/version.c
64@@ -742,6 +742,8 @@ static char *(features[]) =
65
66 static int included_patches[] =
67 { /* Add new patch number below this line */
68+/**/
69+ 3489,
70 /**/
71 3487,
72 /**/