From: mfranz Date: Wed, 9 Jul 2008 19:35:53 +0000 (+0000) Subject: don't run the help browser from a property that a user could have X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1ace68e836374eb762daea0d09de8bd520dfa54f;p=flightgear.git don't run the help browser from a property that a user could have changed to something evil, but rather make sure that the browser string can be trusted. (TODO: change system() to vfork()/execvp() ?) --- diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index 2c96b0e31..ac2e7d4b6 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -101,9 +101,6 @@ extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start, const __fg_gui_fn_t __fg_gui_fn[] = { - - // File - {"reInit", reInit}, #ifdef TR_HIRES_SNAP {"dumpHiResSnapShot", fgHiResDumpWrapper}, #endif @@ -214,13 +211,13 @@ void helpCb () #if !defined(WIN32) - string help_app = fgGetString("/sim/startup/browser-app"); + command = globals->get_browser(); + string::size_type pos; + if ((pos = command.find("%u", 0)) != string::npos) + command.replace(pos, 2, path.str()); + else + command += " " + path.str(); - if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) { - command = help_app + " -remote \"openURL(" + path.str() + ")\""; - } else { - command = help_app + " " + path.str(); - } command += " &"; system( command.c_str() ); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 6a83efb41..e52616ab2 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1390,6 +1390,8 @@ bool fgInitGeneral() { } SG_LOG( SG_GENERAL, SG_INFO, "FG_ROOT = " << '"' << root << '"' << endl ); + globals->set_browser(fgGetString("/sim/startup/browser-app", "firefox %u")); + #if defined(FX) && defined(XMESA) // initialize full screen flag globals->set_fullscreen(false); diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 9182326ee..0d830b3bb 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -116,6 +116,8 @@ private: // Roots of FlightGear scenery tree string_list fg_scenery; + string browser; + // Fullscreen mode for old 3DFX cards. #if defined(FX) && defined(XMESA) bool fullscreen; @@ -238,6 +240,9 @@ public: inline const string_list &get_fg_scenery () const { return fg_scenery; } void set_fg_scenery (const string &scenery); + inline const string &get_browser () const { return browser; } + void set_browser (const string &b) { browser = b; } + #if defined(FX) && defined(XMESA) inline bool get_fullscreen() const { return fullscreen; } inline bool set_fullscreen( bool f ) { fullscreen = f; }