]> git.mxchange.org Git - flightgear.git/commitdiff
set_fg_root: prevent circumvention of the Nasal security code through
authormfranz <mfranz>
Mon, 16 Jun 2008 07:46:55 +0000 (07:46 +0000)
committermfranz <mfranz>
Mon, 16 Jun 2008 07:46:55 +0000 (07:46 +0000)
pre-setting and write-protecting /sim/fg-root in *-set.xml files

src/Main/globals.cxx

index e028c94171a8bd48e4e6887e47c683ecb5f3f0b9..c956180a8888646d40f7565289a9ba9bd30ac931 100644 (file)
@@ -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) {