0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.1.0881: can execute shell commands in rvim through interfaces

Problem:    Can execute shell commands in rvim through interfaces.
Solution:   Disable using interfaces in restricted mode. Allow for writing
            file with writefile(), histadd() and a few others.
This commit is contained in:
Bram Moolenaar
2019-02-08 14:34:10 +01:00
parent c6ddce3f2c
commit 8c62a08faf
8 changed files with 151 additions and 18 deletions

View File

@@ -971,6 +971,7 @@ VIM_init(void)
#ifdef DYNAMIC_PERL
static char *e_noperl = N_("Sorry, this command is disabled: the Perl library could not be loaded.");
#endif
static char *e_perlsandbox = N_("E299: Perl evaluation forbidden in sandbox without the Safe module");
/*
* ":perl"
@@ -1019,13 +1020,12 @@ ex_perl(exarg_T *eap)
vim_free(script);
}
#ifdef HAVE_SANDBOX
if (sandbox)
if (sandbox || secure)
{
safe = perl_get_sv("VIM::safe", FALSE);
# ifndef MAKE_TEST /* avoid a warning for unreachable code */
if (safe == NULL || !SvTRUE(safe))
emsg(_("E299: Perl evaluation forbidden in sandbox without the Safe module"));
emsg(_(e_perlsandbox));
else
# endif
{
@@ -1037,7 +1037,6 @@ ex_perl(exarg_T *eap)
}
}
else
#endif
perl_eval_sv(sv, G_DISCARD | G_NOARGS);
SvREFCNT_dec(sv);
@@ -1298,13 +1297,12 @@ do_perleval(char_u *str, typval_T *rettv)
ENTER;
SAVETMPS;
#ifdef HAVE_SANDBOX
if (sandbox)
if (sandbox || secure)
{
safe = get_sv("VIM::safe", FALSE);
# ifndef MAKE_TEST /* avoid a warning for unreachable code */
if (safe == NULL || !SvTRUE(safe))
emsg(_("E299: Perl evaluation forbidden in sandbox without the Safe module"));
emsg(_(e_perlsandbox));
else
# endif
{
@@ -1320,7 +1318,6 @@ do_perleval(char_u *str, typval_T *rettv)
}
}
else
#endif /* HAVE_SANDBOX */
sv = eval_pv((char *)str, 0);
if (sv) {