]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0517: quickfix: can set quickfixtextfunc in restricted/sandbox mode v9.2.0517
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 23 May 2026 18:16:22 +0000 (18:16 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 23 May 2026 18:21:22 +0000 (18:21 +0000)
Problem:  quickfix: can set quickfixtextfunc in restricted/sandbox mode
          (tacdm)
Solution: Disallow setting the quickfixtextfunc option from a sandbox
          and restricted mode (Yegappan Lakshmanan).

closes: #20305

Co-Authored-by: tacdm
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/quickfix.c
src/testdir/test_quickfix.vim
src/testdir/test_restricted.vim
src/version.c

index feeec181257576ac1c210cea23f76b67ba9c5de6..3fe015ee58c6bbae06caa1db377de982adf31d23 100644 (file)
@@ -8173,13 +8173,16 @@ qf_setprop_curidx(qf_info_T *qi, qf_list_T *qfl, dictitem_T *di)
 }
 
 /*
- * Set the current index in the specified quickfix list
+ * Set the 'quickfixtextfunc' in the specified quickfix/location list
  */
     static int
 qf_setprop_qftf(qf_info_T *qi UNUSED, qf_list_T *qfl, dictitem_T *di)
 {
     callback_T cb;
 
+    if (check_restricted() || check_secure())
+       return FAIL;
+
     free_callback(&qfl->qf_qftf_cb);
     cb = get_callback(&di->di_tv);
     if (cb.cb_name == NULL || *cb.cb_name == NUL)
index 64ec97f5047117606f733d69cd1b981e9695f521..e1dbaa7c59b2d1b5bbbc8b4a963ebc2462824e42 100644 (file)
@@ -7028,4 +7028,38 @@ func Test_efm_overlongline()
   call setqflist([], 'f')
 endfunc
 
+func Xtest_set_qftf_in_sandbox(cchar)
+  call s:setup_commands(a:cchar)
+
+  call g:Xsetlist([{'filename': 'test.c', 'lnum': 1, 'text': 'trigger'}])
+  let g:qftf_fn_called = v:false
+  func Qftf_Fn(d)
+    let g:qftf_fn_called = v:true
+    return []
+  endfunc
+
+  let g:caught_exception = v:false
+  try
+    sandbox call g:Xsetlist([], 'a', #{quickfixtextfunc: 'g:Qftf_Fn'})
+  catch /E48:/
+    let g:caught_exception = v:true
+  endtry
+  copen
+  cclose
+
+  call assert_equal(v:true, g:caught_exception)
+  call assert_equal(v:false, g:qftf_fn_called)
+
+  delfunc Qftf_Fn
+  unlet g:caught_exception
+  unlet g:qftf_fn_called
+  %bw!
+endfunc
+
+" Test for setting the 'quickfixtextfunc' in a sandbox
+func Test_set_qftf_in_sandbox()
+  call Xtest_set_qftf_in_sandbox('c')
+  call Xtest_set_qftf_in_sandbox('l')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index d9810826a0bef10cdc6ae10fd2bf795416c88da0..21133089eeaadabfa924a1e923e7ea71733eb2cb 100644 (file)
@@ -95,6 +95,7 @@ func Test_restricted_mode()
     if has('unix')
       call assert_fails('cd `pwd`', 'E145:')
     endif
+    call assert_fails("call setqflist([], 'a', {'id': 1, 'quickfixtextfunc': 'tr'})", 'E145:')
 
     call writefile(v:errors, 'Xresult')
     qa!
index 92eea5baa28a7c183a9dbec4e26d5f3f351c65ba..f3dd63e77549f7e02b015a93dc9529c65cd5ac60 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    517,
 /**/
     516,
 /**/