1
0
Fork 0

partly revert last change: thisfunc() isn't safe enough for this purpose

This commit is contained in:
mfranz 2008-07-23 00:41:18 +00:00
parent 7bbbfa6a8e
commit fee6139da5
2 changed files with 4 additions and 3 deletions

View file

@ -210,7 +210,7 @@ var writexml = func(path, node, indent = "\t", prefix = "___") {
# Redefine io.open() such that files can only be opened under authorized directories.
#
_setlistener("/sim/signals/nasal-dir-initialized", func {
var self = thisfunc();
var thislistener = thisfunc();
var root = string.fixpath(getprop("/sim/fg-root"));
var home = string.fixpath(getprop("/sim/fg-home"));
var config = "Nasal/IOrules";
@ -267,6 +267,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
var fixpath = string.fixpath; # safe copies
var match = string.match;
var die = die;
var caller = caller;
var valid = func(path, rules) {
var fpath = fixpath(path);
@ -291,7 +292,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
var _closure = globals.closure;
globals.closure = func(fn, level = 0) {
if(fn != self and fn != thisfunc() and fn != io_open)
if(fn != thislistener and fn != caller(0)[1] and fn != io_open)
return _closure(fn, level);
die("closure(): query denied (unauthorized access)\n ");

View file

@ -140,7 +140,7 @@ match = func(str, patt) {
return 1;
for (; s < size(str); s += 1)
if (thisfunc()(substr(str, s), substr(patt, p)))
if (caller(0)[1](substr(str, s), substr(patt, p)))
return 1;
continue;