summaryrefslogtreecommitdiffstats
path: root/debian/patches/CVE-2022-1621.patch
blob: 62b4eecfa41015af42c92a62cdb0c248e79847ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
From 7c824682d2028432ee082703ef0ab399867a089b Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Sun, 8 May 2022 22:32:58 +0100
Subject: [PATCH] patch 8.2.4919: can add invalid bytes with :spellgood

Problem:    Can add invalid bytes with :spellgood.
Solution:   Check for a valid word string.
---
 src/errors.h                    |  4 ++++
 src/mbyte.c                     |  2 +-
 src/spellfile.c                 | 10 ++++++++++
 src/testdir/test_spell_utf8.vim |  5 +++++
 src/version.c                   |  2 ++
 5 files changed, 22 insertions(+), 1 deletion(-)

From fe978c2b6bb9d897d962595a4a51dd7a71dc8e89 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Sun, 8 May 2022 22:43:51 +0100
Subject: [PATCH] patch 8.2.4921: spell test fails because of new illegal byte
 check

Problem:    Spell test fails because of new illegal byte check.
Solution:   Remove the test.
---
 src/testdir/test_spell.vim | 8 --------
 src/version.c              | 2 ++
 2 files changed, 2 insertions(+), 8 deletions(-)

--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -4047,7 +4047,7 @@ theend:
     convert_setup(&vimconv, NULL, NULL);
 }
 
-#if defined(FEAT_GUI_GTK) || defined(PROTO)
+#if defined(FEAT_GUI_GTK) || defined(FEAT_SPELL) || defined(PROTO)
 /*
  * Return TRUE if string "s" is a valid utf-8 string.
  * When "end" is NULL stop at the first NUL.
--- a/src/spellfile.c
+++ b/src/spellfile.c
@@ -4361,6 +4361,10 @@ store_word(
     int		res = OK;
     char_u	*p;
 
+    // Avoid adding illegal bytes to the word tree.
+    if (enc_utf8 && !utf_valid_string(word, NULL))
+	return FAIL;
+
     (void)spell_casefold(word, len, foldword, MAXWLEN);
     for (p = pfxlist; res == OK; ++p)
     {
@@ -6167,6 +6171,12 @@ spell_add_word(
     int		i;
     char_u	*spf;
 
+    if (enc_utf8 && !utf_valid_string(word, NULL))
+    {
+	emsg(_("E1280: Illegal character in word"));
+	return;
+    }
+
     if (idx == 0)	    /* use internal wordlist */
     {
 	if (int_wordlist == NULL)
--- a/src/testdir/test_spell.vim
+++ b/src/testdir/test_spell.vim
@@ -476,16 +476,6 @@ func RunGoodBad(good, bad, expected_word
   bwipe!
 endfunc
 
-func Test_spell_single_word()
-  set spell
-  new
-  silent! norm 0R00
-  spell! ��
-  silent 0norm 0r$ Dvz=
-  set nospell
-  bwipe!
-endfunc
-
 let g:test_data_aff1 = [
       \"SET ISO8859-1",
       \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
@@ -936,3 +926,8 @@ let g:test_data_aff_sal = [
       \"SAL Z                    S",
       \ ]
 
+" Invalid bytes may cause trouble when creating the word list.
+func Test_check_for_valid_word()
+  call assert_fails("spellgood! 0\xac", 'E1280:')
+endfunc
+
--- a/src/version.c
+++ b/src/version.c
@@ -796,6 +796,10 @@ static int included_patches[] =
 /**/
     5024,
 /**/
+    4921,
+/**/
+    4919,
+/**/
     4899,
 /**/
     4428,