patch 9.2.0198: cscope: can escape from restricted mode

Commit: 
https://github.com/vim/vim/commit/2f5fe8827e38eae8f5289a164afae442454893f6
Author: Christian Brabandt <[email protected]>
Date:   Wed Mar 18 21:27:38 2026 +0000

    patch 9.2.0198: cscope: can escape from restricted mode
    
    Problem:  cscope: can escape from restricted mode (pyllyukko)
    Solution: Disallow :cscope in restricted mode (like :grep),
              add a tests for restricted mode using :grep and :cscope
    
    closes: #19731
    
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 2106a1e40..79536bc98 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -1,4 +1,4 @@
-*version9.txt* For Vim version 9.2.  Last change: 2026 Mar 17
+*version9.txt* For Vim version 9.2.  Last change: 2026 Mar 18
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -52600,6 +52600,8 @@ Restricted mode~
 Using external diff mode or setting environment variables is no longer allowed
 when Vim is running in |restricted-mode|.
 
+Using |:cscope| is no longer allowed.
+
 Other ~
 -----
 - The new |xdg.vim| script for full XDG compatibility is included.
diff --git a/src/if_cscope.c b/src/if_cscope.c
index 5c8f9ff47..10437a532 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -254,6 +254,9 @@ do_cscope_general(
 {
     cscmd_T *cmdp;
 
+    if (check_restricted())
+       return;
+
     if ((cmdp = cs_lookup_cmd(eap)) == NULL)
     {
        cs_help(eap);
diff --git a/src/testdir/test_restricted.vim b/src/testdir/test_restricted.vim
index 2d8f483c2..2d8c8ce5f 100644
--- a/src/testdir/test_restricted.vim
+++ b/src/testdir/test_restricted.vim
@@ -176,4 +176,48 @@ func Test_restricted_env()
   call delete('XResult_env')
 endfunc
 
+func Test_restricted_grep()
+  CheckScreendump
+
+  let lines =<< trim END
+    let result = 'okay'
+    try
+      " Try to use grep to execute an external command
+      grep 'Vim' ./*.vim
+    catch /^Vim\%((\S\+)\)\=:E145:/
+      let result = 'grep-blocked'
+    endtry
+    call writefile([result], 'XResult_grep')
+    qa!
+  END
+
+  call writefile(lines, 'Xrestricted_grep', 'D')
+  if RunVim([], [], '-Z --clean -S Xrestricted_grep')
+    call assert_equal(['grep-blocked'], readfile('XResult_grep'))
+  endif
+  call delete('XResult_grep')
+endfunc
+
+func Test_restricted_cscope()
+  CheckFeature cscope
+
+  " File does not exist, but shouldn't matter, it must be disallowed
+  let lines =<< trim END
+    let result = 'okay'
+    try
+      cscope add Xfoobar.out
+    catch /^Vim\%((\S\+)\)\=:E145:/
+      let result = 'blocked'
+    endtry
+    call writefile([result], 'XResult_cscope')
+    qa!
+  END
+
+  call writefile(lines, 'Xrestricted_cscope', 'D')
+  if RunVim([], [], '-Z --clean -S Xrestricted_cscope')
+    call assert_equal(['blocked'], readfile('XResult_cscope'))
+  endif
+  call delete('XResult_cscope')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 9d5bbf02d..b47f10e36 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    198,
 /**/
     197,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1w2ySs-00C7Dy-4x%40256bit.org.

Raspunde prin e-mail lui