~ubuntu-branches/ubuntu/vivid/gnash/vivid-proposed

« back to all changes in this revision

Viewing changes to libcore/movie_root.cpp

  • Committer: Package Import Robot
  • Author(s): Gabriele Giacone
  • Date: 2012-06-30 02:35:32 UTC
  • mfrom: (1.1.20)
  • Revision ID: package-import@ubuntu.com-20120630023532-go61oics8o04jek1
Tags: 0.8.11~git20120629-1
* Git snapshot.
  + IPv6 support.
  + Fix FTBFS with gcc 4.7 and clang.
  + Fix opening of external URL with gnash standalone.
* Remove gstreamer0.10-fluendo-mp3 from runtime deps (Closes: #679527).
* Use sensible-browser instead of xdg-open (Closes: #597195).
* Set NoDiplay=true in desktop icons (Closes: #679573). 
* Switch source and binary to xz compression.
* Remove gcc4.7 and CVE-2012-1175 patches.
* Add hardening lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2140
2140
        std::string command = rcfile.getURLOpenerFormat();
2141
2141
 
2142
2142
        /// Try to avoid letting flash movies execute
2143
 
        /// arbitrary commands (sic)
2144
 
        ///
2145
 
        /// Maybe we should exec here, but if we do we might have problems
2146
 
        /// with complex urlOpenerFormats like:
2147
 
        ///    firefox -remote 'openurl(%u)'
2148
 
        ///
2149
 
        std::string safeurl = url.encode(urlstr);
 
2143
        /// arbitrary commands (sic).
 
2144
        ///
 
2145
        /// NOTE: it is assumed that the user-provided command
 
2146
        ///       puts the url place-holder within single quotes.
 
2147
        ///       Failing that, there will be the possibility 
 
2148
        ///       for malicious SWF files to run arbitrary commands.
 
2149
        /// 
 
2150
        ///
 
2151
        /// Check safety of user provided command
 
2152
        ///
 
2153
        /// TODO: improve this check
 
2154
        ///       - quote nested in double quote
 
2155
        ///       - %u after second quote
 
2156
        ///       - use regexp ?
 
2157
        /// TODO: check only once
 
2158
        ///
 
2159
        bool command_is_safe = false;
 
2160
        do {
 
2161
            std::string::size_type loc = command.find('\'');
 
2162
            if ( loc == std::string::npos ) break;
 
2163
            loc = command.find("%u", loc);
 
2164
            if ( loc == std::string::npos ) break;
 
2165
            loc = command.find('\'', loc);
 
2166
            if ( loc == std::string::npos ) break;
 
2167
            command_is_safe = true;
 
2168
        } while (0);
 
2169
 
 
2170
        if ( ! command_is_safe ) {
 
2171
            log_error("The '%%u' token in urlOpenerFormat rc directive should be within single quotes");
 
2172
            return;
 
2173
        } 
 
2174
 
 
2175
        std::string safeurl = urlstr; 
 
2176
        boost::replace_all(safeurl, "'", "'\\''");
 
2177
 
2150
2178
        boost::replace_all(command, "%u", safeurl);
2151
 
        
 
2179
 
2152
2180
        log_debug("Launching URL: %s", command);
2153
2181
        const int ret = std::system(command.c_str());
2154
2182
        if (ret == -1) {