File: patch-8.1.0540-may-evaluate-insecure-value-when-appending.patch

package info (click to toggle)
vim 2%3A8.0.0197-4%2Bdeb9u3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 60,600 kB
  • sloc: ansic: 320,650; cpp: 4,144; makefile: 3,536; perl: 1,179; awk: 715; sh: 682; xml: 526; lisp: 501; cs: 458; python: 410; asm: 114; csh: 6
file content (103 lines) | stat: -rw-r--r-- 3,123 bytes parent folder | download
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
From: Bram Moolenaar <Bram@vim.org>
Date: Tue, 20 Nov 2018 14:27:07 +0100
Subject: patch 8.1.0540: may evaluate insecure value when appending to option

Problem:    May evaluate insecure value when appending to option.
Solution:   Set the secure flag when changing an option that was previously
            set insecurely.  Also allow numbers for the characters from
            'spelllang' that are used for LANG.vim.

(cherry picked from commit 247bb7e43b47eb8407a1111bed60b61aceda52ad)

Signed-off-by: James McCoy <jamessan@debian.org>
---
 src/option.c  | 41 ++++++++++++++++++++++++++++++++++-------
 src/version.c |  2 ++
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/src/option.c b/src/option.c
index 1754109..81e4740 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4488,6 +4488,8 @@ do_set(
 	    }
 	    else
 	    {
+		int value_is_replaced = !prepending && !adding && !removing;
+
 		if (flags & P_BOOL)		    /* boolean */
 		{
 		    if (nextchar == '=' || nextchar == ':')
@@ -4979,10 +4981,36 @@ do_set(
 			    saved_origval = vim_strsave(origval);
 #endif
 
-			/* Handle side effects, and set the global value for
-			 * ":set" on local options. */
-			errmsg = did_set_string_option(opt_idx, (char_u **)varp,
-				new_value_alloced, oldval, errbuf, opt_flags);
+			{
+			    long_u *p = insecure_flag(opt_idx, opt_flags);
+			    int	    did_inc_secure = FALSE;
+
+			    // When an option is set in the sandbox, from a
+			    // modeline or in secure mode, then deal with side
+			    // effects in secure mode.  Also when the value was
+			    // set with the P_INSECURE flag and is not
+			    // completely replaced.
+			    if (secure
+#ifdef HAVE_SANDBOX
+				    || sandbox != 0
+#endif
+				    || (opt_flags & OPT_MODELINE)
+				    || (!value_is_replaced && (*p & P_INSECURE)))
+			    {
+				did_inc_secure = TRUE;
+				++secure;
+			    }
+
+			    // Handle side effects, and set the global value for
+			    // ":set" on local options. Note: when setting 'syntax'
+			    // or 'filetype' autocommands may be triggered that can
+			    // cause havoc.
+			    errmsg = did_set_string_option(opt_idx, (char_u **)varp,
+				    new_value_alloced, oldval, errbuf, opt_flags);
+
+			    if (did_inc_secure)
+				--secure;
+			}
 
 			/* If error detected, print the error message. */
 			if (errmsg != NULL)
@@ -5039,8 +5067,7 @@ do_set(
 		}
 
 		if (opt_idx >= 0)
-		    did_set_option(opt_idx, opt_flags,
-					 !prepending && !adding && !removing);
+		    did_set_option(opt_idx, opt_flags, value_is_replaced);
 	    }
 
 skip:
@@ -7409,7 +7436,7 @@ did_set_string_option(
 	     * '.encoding'.
 	     */
 	    for (p = q; *p != NUL; ++p)
-		if (!ASCII_ISALPHA(*p) && *p != '-')
+		if (!ASCII_ISALNUM(*p) && *p != '-')
 		    break;
 	    if (p > q)
 	    {
diff --git a/src/version.c b/src/version.c
index c9c08c7..0365be3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -1195,6 +1195,8 @@ static int included_patches[] =
  */
 static char *(extra_patches[]) =
 {   /* Add your patch description below this line */
+/**/
+    "8.1.0540",
 /**/
     "8.1.0539",
 /**/