]> granicus.if.org Git - vim/commitdiff
patch 8.1.1365: source command doesn't check for the sandbox v8.1.1365
authorBram Moolenaar <Bram@vim.org>
Wed, 22 May 2019 20:38:25 +0000 (22:38 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 22 May 2019 20:38:25 +0000 (22:38 +0200)
Problem:    Source command doesn't check for the sandbox. (Armin Razmjou)
Solution:   Check for the sandbox when sourcing a file.

src/getchar.c
src/testdir/test_source.vim
src/version.c

index 9379a6a8d4530e456f5978045127eba77b6734ca..debad7efd2cde31641cc563f638bf634602dc389 100644 (file)
@@ -1407,6 +1407,12 @@ openscript(
        emsg(_(e_nesting));
        return;
     }
+
+    // Disallow sourcing a file in the sandbox, the commands would be executed
+    // later, possibly outside of the sandbox.
+    if (check_secure())
+       return;
+
 #ifdef FEAT_EVAL
     if (ignore_script)
        /* Not reading from script, also don't open one.  Warning message? */
index a33d286e75526434e6867dd0a23bd38175345586..5166bafb1546d6fd3991307e22ea678be9c46fee 100644 (file)
@@ -36,3 +36,12 @@ func Test_source_cmd()
   au! SourcePre
   au! SourcePost
 endfunc
+
+func Test_source_sandbox()
+  new
+  call writefile(["Ohello\<Esc>"], 'Xsourcehello')
+  source! Xsourcehello | echo
+  call assert_equal('hello', getline(1))
+  call assert_fails('sandbox source! Xsourcehello', 'E48:')
+  bwipe!
+endfunc
index b0736df46a786b0d0271c1070a9d326ca1cc4022..b2fcbfb14c1fe09db9be5e6c7303ed4d43e4b01f 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1365,
 /**/
     1364,
 /**/