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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
From: Bram Moolenaar <Bram@vim.org>
Date: Fri, 21 Dec 2018 13:03:28 +0100
Subject: patch 8.1.0613: when executing an insecure function the secure flag
is stuck
Problem: When executing an insecure function the secure flag is stuck.
(Gabriel Barta)
Solution: Restore "secure" instead of decrementing it. (closes #3705)
(cherry picked from commit 48f377a476e4a3312aa0e3535aba170484b59483)
Signed-off-by: James McCoy <jamessan@debian.org>
---
src/buffer.c | 3 ++-
src/option.c | 19 ++++++++-----------
src/testdir/test_autocmd.vim | 23 +++++++++++++++++++++++
src/version.c | 2 ++
4 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/src/buffer.c b/src/buffer.c
index 2bcb034..b5a47d6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5471,6 +5471,7 @@ chk_modeline(
if (*s != NUL) /* skip over an empty "::" */
{
+ int secure_save = secure;
#ifdef FEAT_EVAL
save_SID = current_SID;
current_SID = SID_MODELINE;
@@ -5480,7 +5481,7 @@ chk_modeline(
retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags);
- --secure;
+ secure = secure_save;
#ifdef FEAT_EVAL
current_SID = save_SID;
#endif
diff --git a/src/option.c b/src/option.c
index 5c64cfe..afba466 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4984,7 +4984,7 @@ do_set(
{
long_u *p = insecure_flag(opt_idx, opt_flags);
- int did_inc_secure = FALSE;
+ int secure_saved = secure;
// When an option is set in the sandbox, from a
// modeline or in secure mode, then deal with side
@@ -4997,21 +4997,18 @@ do_set(
#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,
+ // 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, &value_checked);
- if (did_inc_secure)
- --secure;
+ secure = secure_saved;
}
/* If error detected, print the error message. */
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 2a783f4..28ca59e 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -345,3 +345,26 @@ endfunc
func Test_empty_doau()
doau \|
endfunc
+
+func Test_OptionSet_modeline()
+ throw 'Skipped, test_override() missing'
+ call test_override('starting', 1)
+ au! OptionSet
+ augroup set_tabstop
+ au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")})
+ augroup END
+ call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline')
+ set modeline
+ let v:errmsg = ''
+ call assert_fails('split XoptionsetModeline', 'E12:')
+ call assert_equal(7, &ts)
+ call assert_equal('', v:errmsg)
+
+ augroup set_tabstop
+ au!
+ augroup END
+ bwipe!
+ set ts&
+ call delete('XoptionsetModeline')
+ call test_override('starting', 0)
+endfunc
diff --git a/src/version.c b/src/version.c
index 9752cb7..beba433 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.0613",
/**/
"8.1.0547",
/**/
|