From 37a963da92f1a842295bf13391634d714e8b26a6 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Fri, 13 Mar 2015 18:19:48 +0000 Subject: [PATCH] Move Nasal io.open to flightgear --- simgear/nasal/iolib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/simgear/nasal/iolib.c b/simgear/nasal/iolib.c index bbe9004a..b9119017 100644 --- a/simgear/nasal/iolib.c +++ b/simgear/nasal/iolib.c @@ -142,6 +142,9 @@ naRef naIOGhost(naContext c, FILE* f) return naNewGhost(c, &naIOGhostType, ghost); } +#if SG_NASAL_UNRESTRICTED_OPEN +// Allows unrestricted file access, which would be a security hole +// Replaced by the one in flightgear src/Scripting/NasalSys.cxx static naRef f_open(naContext c, naRef me, int argc, naRef* args) { FILE* f; @@ -152,6 +155,7 @@ static naRef f_open(naContext c, naRef me, int argc, naRef* args) if(!f) naRuntimeError(c, strerror(errno)); return naIOGhost(c, f); } +#endif // frees buffer before tossing an error static int getcguard(naContext ctx, FILE* f, void* buf) @@ -244,7 +248,9 @@ static naCFuncItem funcs[] = { { "seek", f_seek }, { "tell", f_tell }, { "flush", f_flush }, +#if SG_NASAL_UNRESTRICTED_OPEN { "open", f_open }, +#endif { "readln", f_readln }, { "stat", f_stat }, { 0 } -- 2.39.5