Blame SOURCES/0001-patch-8.2.4919-can-add-invalid-bytes-with-spellgood.patch

83f671
diff -up vim82/src/errors.h.cve1621 vim82/src/errors.h
83f671
--- vim82/src/errors.h.cve1621	2022-05-24 13:36:23.883370040 +0200
83f671
+++ vim82/src/errors.h	2022-05-24 13:36:47.665487703 +0200
83f671
@@ -387,3 +387,7 @@ EXTERN char e_resulting_text_too_long[]
83f671
 EXTERN char e_string_or_function_required_for_arrow_parens_expr[]
83f671
 	INIT(= N_("E1275: String or function required for ->(expr)"));
83f671
 #endif
83f671
+#ifdef FEAT_SPELL
83f671
+EXTERN char e_illegal_character_in_word[]
83f671
+	INIT(= N_("E1280: Illegal character in word"));
83f671
+#endif
83f671
diff -up vim82/src/mbyte.c.cve1621 vim82/src/mbyte.c
83f671
--- vim82/src/mbyte.c.cve1621	2021-03-22 10:02:42.000000000 +0100
83f671
+++ vim82/src/mbyte.c	2022-05-24 13:36:23.884370045 +0200
83f671
@@ -4181,7 +4181,7 @@ theend:
83f671
     convert_setup(&vimconv, NULL, NULL);
83f671
 }
83f671
 
83f671
-#if defined(FEAT_GUI_GTK) || defined(PROTO)
83f671
+#if defined(FEAT_GUI_GTK) || defined(FEAT_SPELL) || defined(PROTO)
83f671
 /*
83f671
  * Return TRUE if string "s" is a valid utf-8 string.
83f671
  * When "end" is NULL stop at the first NUL.
83f671
diff -up vim82/src/spellfile.c.cve1621 vim82/src/spellfile.c
83f671
--- vim82/src/spellfile.c.cve1621	2021-03-22 10:02:42.000000000 +0100
83f671
+++ vim82/src/spellfile.c	2022-05-24 13:36:23.885370049 +0200
83f671
@@ -4391,6 +4391,10 @@ store_word(
83f671
     int		res = OK;
83f671
     char_u	*p;
83f671
 
83f671
+    // Avoid adding illegal bytes to the word tree.
83f671
+    if (enc_utf8 && !utf_valid_string(word, NULL))
83f671
+	return FAIL;
83f671
+
83f671
     (void)spell_casefold(word, len, foldword, MAXWLEN);
83f671
     for (p = pfxlist; res == OK; ++p)
83f671
     {
83f671
@@ -6191,6 +6195,12 @@ spell_add_word(
83f671
     int		i;
83f671
     char_u	*spf;
83f671
 
83f671
+    if (enc_utf8 && !utf_valid_string(word, NULL))
83f671
+    {
83f671
+	emsg(_(e_illegal_character_in_word));
83f671
+	return;
83f671
+    }
83f671
+
83f671
     if (idx == 0)	    // use internal wordlist
83f671
     {
83f671
 	if (int_wordlist == NULL)