From 88839f0b7aba1242dc19f38927624d525ca50607 Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 16 Jun 2008 07:46:55 +0000 Subject: [PATCH] set_fg_root: prevent circumvention of the Nasal security code through pre-setting and write-protecting /sim/fg-root in *-set.xml files --- src/Main/globals.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index e028c9417..c956180a8 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -169,7 +169,7 @@ FGGlobals::~FGGlobals() // set the fg_root path void FGGlobals::set_fg_root (const string &root) { fg_root = root; - + // append /data to root if it exists SGPath tmp( fg_root ); tmp.append( "data" ); @@ -178,7 +178,12 @@ void FGGlobals::set_fg_root (const string &root) { fg_root += "/data"; } - fgSetString("/sim/fg-root", fg_root.c_str()); + // remove /sim/fg-root before writing to prevent hijacking + SGPropertyNode *n = fgGetNode("/sim", true); + n->removeChild("fg-root", 0, false); + n = n->getChild("fg-root", 0, true); + n->setStringValue(fg_root.c_str()); + n->setAttribute(SGPropertyNode::WRITE, false); } void FGGlobals::set_fg_scenery (const string &scenery) {