To: vim-dev@vim.org Subject: Patch 6.2.265 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.265 Problem: Although ":set" is not allowed in the sandbox, ":let &opt = val" works. Solution: Do allow changing options in the sandbox, but not the ones that can't be changed from a modeline. Files: src/ex_cmds.h, src/option.c *** ../vim-6.2.264/src/ex_cmds.h Tue Feb 10 19:35:15 2004 --- src/ex_cmds.h Mon Feb 16 17:06:54 2004 *************** *** 687,693 **** EX(CMD_scscope, "scscope", do_scscope, EXTRA|NOTRLCOM|SBOXOK), EX(CMD_set, "set", ex_set, ! TRLBAR|EXTRA|CMDWIN), EX(CMD_setfiletype, "setfiletype", ex_setfiletype, TRLBAR|EXTRA|NEEDARG|CMDWIN), EX(CMD_setglobal, "setglobal", ex_set, --- 687,693 ---- EX(CMD_scscope, "scscope", do_scscope, EXTRA|NOTRLCOM|SBOXOK), EX(CMD_set, "set", ex_set, ! TRLBAR|EXTRA|CMDWIN|SBOXOK), EX(CMD_setfiletype, "setfiletype", ex_setfiletype, TRLBAR|EXTRA|NEEDARG|CMDWIN), EX(CMD_setglobal, "setglobal", ex_set, *** ../vim-6.2.264/src/option.c Wed Feb 4 21:42:30 2004 --- src/option.c Tue Feb 17 11:17:55 2004 *************** *** 3393,3398 **** --- 3425,3439 ---- goto skip; } + #ifdef HAVE_SANDBOX + /* Disallow changing some options in the sandbox */ + if (sandbox > 0 && (flags & P_SECURE)) + { + errmsg = (char_u *)_(e_sandbox); + goto skip; + } + #endif + if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) { arg += len; *************** *** 6950,6970 **** { int opt_idx; char_u *varp; opt_idx = findoption(name); if (opt_idx == -1) EMSG2(_("E355: Unknown option: %s"), name); - else if (options[opt_idx].flags & P_STRING) - set_string_option(opt_idx, string, opt_flags); else { ! varp = get_varp(&options[opt_idx]); ! if (varp != NULL) /* hidden option is not changed */ { ! if (options[opt_idx].flags & P_NUM) ! (void)set_num_option(opt_idx, varp, number, NULL, opt_flags); ! else ! (void)set_bool_option(opt_idx, varp, (int)number, opt_flags); } } } --- 7007,7038 ---- { int opt_idx; char_u *varp; + int flags; opt_idx = findoption(name); if (opt_idx == -1) EMSG2(_("E355: Unknown option: %s"), name); else { ! flags = options[opt_idx].flags; ! #ifdef HAVE_SANDBOX ! /* Disallow changing some options in the sandbox */ ! if (sandbox > 0 && (flags & P_SECURE)) ! EMSG(_(e_sandbox)); ! else ! #endif ! if (flags & P_STRING) ! set_string_option(opt_idx, string, opt_flags); ! else { ! varp = get_varp(&options[opt_idx]); ! if (varp != NULL) /* hidden option is not changed */ ! { ! if (flags & P_NUM) ! (void)set_num_option(opt_idx, varp, number, NULL, opt_flags); ! else ! (void)set_bool_option(opt_idx, varp, (int)number, opt_flags); ! } } } } *** ../vim-6.2.264/src/version.c Tue Feb 17 20:22:36 2004 --- src/version.c Tue Feb 17 20:38:04 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 265, /**/ -- In Joseph Heller's novel "Catch-22", the main character tries to get out of a war by proving he is crazy. But the mere fact he wants to get out of the war only shows he isn't crazy -- creating the original "Catch-22". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///