gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_start-


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_start-434-ge113732
Date: Wed, 30 Mar 2011 12:12:33 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  e11373272d407db9f88f1845d5c9554e07d3aaf6 (commit)
      from  4c801f1f78391bfab7f6abd7931c98087c24b143 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=e11373272d407db9f88f1845d5c9554e07d3aaf6


commit e11373272d407db9f88f1845d5c9554e07d3aaf6
Author: Sandro Santilli <address@hidden>
Date:   Wed Mar 30 14:09:43 2011 +0200

    Add support for 'scriptsTimeout', 'scriptsRecursionLimit' and 
'lockScriptLimits' rc directives, testcase their support and use them from 
movie_root.

diff --git a/libbase/gnashrc.in b/libbase/gnashrc.in
index d18463c..40c7155 100644
--- a/libbase/gnashrc.in
+++ b/libbase/gnashrc.in
@@ -242,3 +242,28 @@
 #
 # Default: true
 #set ignoreShowMenu false
+
+# After a given amount of seconds an action script is running the user
+# is given a chance to interrupt them and abort further scripts execution.
+# You can tweak the number of seconds here, useful for quick profiling.
+#
+# Note that SWF tags can override this, see lockScriptLimits to forbid that.
+#
+# Default: 15
+#set scriptsTimeout 
+
+# Scripts are limited in the number of nested function calls they can
+# make. This is primarly aimed at interrupting infinite recursions.
+# You can tweak the max stack depth here.
+#
+# Note that SWF tags can override this, see lockScriptLimits to forbid that.
+#
+# Default: 256
+#set scriptsRecursionLimit 32
+
+# Forbid override of script limits by SWF tag.
+#
+# See scriptsRecursionLimit and scriptsTimeout directive for further info.
+#
+# Default: false
+#set lockScriptLimits true
diff --git a/libbase/rc.cpp b/libbase/rc.cpp
index 31e1de1..55b8d81 100644
--- a/libbase/rc.cpp
+++ b/libbase/rc.cpp
@@ -119,7 +119,10 @@ RcInitFile::RcInitFile()
     _certfile("client.pem"),
     _certdir("/etc/pki/tls"),
     _rootcert("rootcert.pem"),
-    _ignoreShowMenu(true)
+    _ignoreShowMenu(true),
+    _scriptsTimeout(15),
+    _scriptsRecursionLimit(256),
+    _lockScriptLimits(false)
 {
     expandPath(_solsandbox);
     loadFiles();
@@ -606,6 +609,15 @@ RcInitFile::parseFile(const std::string& filespec)
                        ||
                  extractSetting(_ignoreShowMenu, "ignoreShowMenu", variable,
                            value)
+                       ||
+                 extractNumber(_scriptsTimeout, "scriptsTimeout", variable, 
+                         value)
+                       ||
+                 extractNumber(_scriptsRecursionLimit, "scriptsRecursionLimit",
+                         variable, value)
+                       ||
+                 extractSetting(_lockScriptLimits, "lockScriptLimits", 
variable,
+                           value)
             ||
                  cerr << boost::format(_("Warning: unrecognized directive "
                              "\"%s\" in rcfile %s line %d")) 
@@ -767,6 +779,9 @@ RcInitFile::updateFile(const std::string& filespec)
     cmd << "ignoreShowMenu " << _ignoreShowMenu << endl <<
     cmd << "saveStreamingMedia " << _saveStreamingMedia << endl <<    
     cmd << "saveLoadedMedia " << _saveLoadedMedia << endl <<    
+    cmd << "scriptsTimeout " << _scriptsTimeout << endl <<
+    cmd << "scriptsRecursionLimit " << _scriptsRecursionLimit << endl <<
+    cmd << "lockScriptLimits " << _lockScriptLimits << endl <<
    
     // Strings.
 
diff --git a/libbase/rc.h b/libbase/rc.h
index 9d4cfa2..459a3ac 100644
--- a/libbase/rc.h
+++ b/libbase/rc.h
@@ -341,6 +341,18 @@ public:
 
     bool ignoreShowMenu() const { return _ignoreShowMenu; }
 
+    int getScriptsTimeout() const { return _scriptsTimeout; }
+
+    void setScriptsTimeout(int x) { _scriptsTimeout = x; }
+
+    int getScriptsRecursionLimit() const { return _scriptsRecursionLimit; }
+
+    void setScriptsRecursionLimit(int x) { _scriptsRecursionLimit = x; }
+
+    void lockScriptLimits(bool x) { _lockScriptLimits = x; }
+
+    bool lockScriptLimits() const { return _lockScriptLimits; }
+
     void dump();    
 
 protected:
@@ -596,6 +608,16 @@ protected:
     /// Which media player backend to use, no value means use the default.
     /// The default is set in the MediaFactory initialization table.
     std::string _mediahandler;
+
+    /// The number of seconds after which action execution is
+    /// considered to be slow enough to prompt the user for aborting
+    int _scriptsTimeout;
+
+    /// The max actionscript function call stack depth
+    int _scriptsRecursionLimit;
+
+    /// Whether to ignore SWF ScriptLimits tags 
+    bool _lockScriptLimits;
 };
 
 // End of gnash namespace 
diff --git a/libcore/movie_root.cpp b/libcore/movie_root.cpp
index 2383cff..7f26d6e 100644
--- a/libcore/movie_root.cpp
+++ b/libcore/movie_root.cpp
@@ -163,9 +163,8 @@ movie_root::movie_root(const movie_definition& def,
     _showMenu(true),
     _scaleMode(SCALEMODE_SHOWALL),
     _displayState(DISPLAYSTATE_NORMAL),
-    _recursionLimit(256),
-    // TODO: allow gnashrc to set this
-    _timeoutLimit(15),
+    _recursionLimit(), // set in ctor body
+    _timeoutLimit(),   // set in ctor body
     _movieAdvancementDelay(83), // ~12 fps by default
     _lastMovieAdvancement(0),
     _unnamedInstance(0),
@@ -173,6 +172,10 @@ movie_root::movie_root(const movie_definition& def,
 {
     // This takes care of informing the renderer (if present) too.
     setQuality(QUALITY_HIGH);
+
+    gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
+    _recursionLimit = rcfile.getScriptsRecursionLimit();
+    _timeoutLimit = rcfile.getScriptsTimeout();
 }
 
 void
@@ -2157,6 +2160,14 @@ movie_root::setScriptLimits(boost::uint16_t recursion, 
boost::uint16_t timeout)
         return;
     }
 
+    if ( RcInitFile::getDefaultInstance().lockScriptLimits() )
+    {
+        LOG_ONCE( log_debug(_("SWF ScriptLimits tag attempting to set "
+            "recursionLimit=%1% and scriptsTimeout=%2% ignored "
+            "as per rcfile directive"), recursion, timeout) );
+        return;
+    }
+
     // This tag reported in some sources to be ignored for movies
     // below SWF7. However, on Linux with PP version 9, the tag
     // takes effect on SWFs of any version.
diff --git a/testsuite/libbase.all/RcTest.cpp b/testsuite/libbase.all/RcTest.cpp
index 87005f4..d9dda13 100644
--- a/testsuite/libbase.all/RcTest.cpp
+++ b/testsuite/libbase.all/RcTest.cpp
@@ -300,6 +300,19 @@ main (int /*argc*/, char** /*argv*/) {
         runtest.fail ("getMediaHandler gives " + rc.getMediaHandler() );
     }
 
+    if ( rc.getScriptsTimeout() == 15 ) {
+        runtest.pass ("getScriptsTimeout gives 15");
+    } else {
+        runtest.fail ("getScriptsTimeout doesn't gives 15");
+    }
+
+    if ( rc.getScriptsRecursionLimit() == 256 ) {
+        runtest.pass ("getScriptsRecursionLimit gives 256");
+    } else {
+        runtest.fail ("getScriptsRecursionLimit doesn't gives 256");
+    }
+
+
     // Parse a second file
     if (rc.parseFile("gnashrc-local")) {
 
@@ -352,6 +365,18 @@ main (int /*argc*/, char** /*argv*/) {
             runtest.fail ("getMediaHandler gives " + rc.getMediaHandler() );
         }
 
+        if ( rc.getScriptsTimeout() == 2 ) {
+            runtest.pass ("getScriptsTimeout gives 2");
+        } else {
+            runtest.fail ("getScriptsTimeout doesn't gives 2");
+        }
+
+        if ( rc.getScriptsRecursionLimit() == 32 ) {
+            runtest.pass ("getScriptsRecursionLimit gives 32");
+        } else {
+            runtest.fail ("getScriptsRecursionLimit doesn't gives 32");
+        }
+
     }
 }
 
diff --git a/testsuite/libbase.all/gnashrc-local.in 
b/testsuite/libbase.all/gnashrc-local.in
index 6dad1f0..5f3e8bd 100644
--- a/testsuite/libbase.all/gnashrc-local.in
+++ b/testsuite/libbase.all/gnashrc-local.in
@@ -12,3 +12,9 @@ set Renderer fakeRenderer
 
 # Use arbitrary renderer
 set MediaHandler fakeMediaHandler
+
+# Override scripts timeout
+set scriptsTimeout 2
+
+# Override scripts recursion limit
+set scriptsRecursionLimit 32

-----------------------------------------------------------------------

Summary of changes:
 libbase/gnashrc.in                     |   25 +++++++++++++++++++++++++
 libbase/rc.cpp                         |   17 ++++++++++++++++-
 libbase/rc.h                           |   22 ++++++++++++++++++++++
 libcore/movie_root.cpp                 |   17 ++++++++++++++---
 testsuite/libbase.all/RcTest.cpp       |   25 +++++++++++++++++++++++++
 testsuite/libbase.all/gnashrc-local.in |    6 ++++++
 6 files changed, 108 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]