[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve... |
Date: |
Wed, 04 Jun 2008 19:54:12 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/06/04 19:54:12
Modified files:
. : ChangeLog
server : as_environment.cpp as_object.cpp movie_root.cpp
movie_root.h
server/swf : ScriptLimitsTag.h
Log message:
* server/movie_root.{cpp,h}: add methods to set and retrieve
script limits.
* server/swf/ScriptLimits.h: inform movie_root of ScriptLimits.
* server/as_environment.cpp: stack limit is affected by the
recursion
limit. Replace snprintf with boost::format.
* server/as_object.cpp: add comments; these recursion
protections
seem not to be present in the pp, which instead times out.
I haven't yet found any recursion form other than stack size
which
is affected by the recursion value.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6819&r2=1.6820
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.134&r2=1.135
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.122&r2=1.123
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.200&r2=1.201
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.133&r2=1.134
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/ScriptLimitsTag.h?cvsroot=gnash&r1=1.1&r2=1.2
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6819
retrieving revision 1.6820
diff -u -b -r1.6819 -r1.6820
--- ChangeLog 4 Jun 2008 19:47:49 -0000 1.6819
+++ ChangeLog 4 Jun 2008 19:54:11 -0000 1.6820
@@ -1,5 +1,15 @@
2008-06-04 Benjamin Wolsey <address@hidden>
+ * server/movie_root.{cpp,h}: add methods to set and retrieve
+ script limits.
+ * server/swf/ScriptLimits.h: inform movie_root of ScriptLimits.
+ * server/as_environment.cpp: stack limit is affected by the recursion
+ limit. Replace snprintf with boost::format.
+ * server/as_object.cpp: add comments; these recursion protections
+ seem not to be present in the pp, which instead times out.
+
+2008-06-04 Benjamin Wolsey <address@hidden>
+
* server/impl.cpp: remove obsolete comment.
2008-06-04 Sandro Santilli <address@hidden>
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -b -r1.134 -r1.135
--- server/as_environment.cpp 27 May 2008 07:56:19 -0000 1.134
+++ server/as_environment.cpp 4 Jun 2008 19:54:11 -0000 1.135
@@ -33,6 +33,7 @@
#include <string>
#include <utility> // for std::pair
#include <boost/algorithm/string/case_conv.hpp>
+#include <boost/format.hpp>
// Define this to have find_target() calls trigger debugging output
//#define DEBUG_TARGET_FINDING 1
@@ -877,18 +878,26 @@
void
as_environment::pushCallFrame(as_function* func)
{
- const unsigned maxstacksize = 255;
- if ( _localFrames.size() == maxstacksize )
+ // The stack size can be changed by the ScriptLimits
+ // tag. There is *no* difference between SWF versions.
+ // TODO: override from gnashrc.
+ const boost::uint16_t maxstacksize =
VM::get().getRoot().getRecursionLimit();
+
+ // Doesn't proceed if the stack size would reach the limit; should
+ // this check be done somewhere after adding to the stack? Would
+ // it make any difference?
+ if ( _localFrames.size() == maxstacksize - 1 )
{
- char buf[256];
- snprintf(buf, 255, _("Max stack count reached (%u)"),
- maxstacksize);
+ std::ostringstream ss;
+ ss << boost::format(_("Max stack count reached (%u)")) %
_localFrames.size();
// throw something
- throw ActionLimitException(buf);
+ throw ActionLimitException(ss.str());
}
+
_localFrames.push_back(CallFrame(func));
+
}
void
Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- server/as_object.cpp 25 May 2008 10:05:20 -0000 1.122
+++ server/as_object.cpp 4 Jun 2008 19:54:11 -0000 1.123
@@ -464,6 +464,10 @@
int i = 0;
boost::intrusive_ptr<as_object> obj = this;
+
+ // This recursion prevention seems not to exist in the PP.
+ // Instead, it stops when its general timeout for the
+ // execution of scripts is reached.
while (obj && visited.insert(obj.get()).second)
{
++i;
@@ -506,6 +510,8 @@
int i = 0;
boost::intrusive_ptr<as_object> obj = get_prototype();
+
+ // TODO: does this recursion protection exist in the PP?
while (obj && visited.insert(obj.get()).second)
{
++i;
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -b -r1.200 -r1.201
--- server/movie_root.cpp 4 Jun 2008 14:02:02 -0000 1.200
+++ server/movie_root.cpp 4 Jun 2008 19:54:12 -0000 1.201
@@ -115,7 +115,9 @@
_hostfd(-1),
_alignMode(0),
_scaleMode(showAll),
- _displayState(normal)
+ _displayState(normal),
+ _recursionLimit(256),
+ _timeoutLimit(15)
{
}
@@ -192,7 +194,7 @@
}
catch (ActionLimitException& al)
{
- log_error(_("ActionLimits hit during setRootMovie: %s."
+ log_error(_("ActionLimits hit during setRootMovie: %s. "
"Disabling scripts"), al.what());
disableScripts();
clearActionQueue();
@@ -2081,6 +2083,21 @@
}
+void
+movie_root::setScriptLimits(boost::uint16_t recursion, boost::uint16_t timeout)
+{
+
+ // 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.
+ log_debug(_("Setting script limits: max recursion %d, "
+ "timeout %d seconds"), recursion, timeout);
+
+ _recursionLimit = recursion;
+ _timeoutLimit = timeout;
+}
+
+
#ifdef USE_SWFTREE
void
movie_root::getMovieInfo(tree<StringPair>& tr, tree<StringPair>::iterator it)
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -b -r1.133 -r1.134
--- server/movie_root.h 2 Jun 2008 09:52:53 -0000 1.133
+++ server/movie_root.h 4 Jun 2008 19:54:12 -0000 1.134
@@ -719,6 +719,37 @@
fsCommandHandle = handler;
}
+ /// Called from the ScriptLimits tag parser to set the
+ /// global script limits. It is expected behaviour that
+ /// each new loaded movie should override this.
+ /// Can be overridden from gnashrc.
+ //
+ /// @param recursion the maximum number of recursions when
+ /// finding 'super'.
+ /// The default value for this (i.e. when no
+ /// ScriptLimits tag is present) is documented to be
+ /// 256, but this may change and appears not to be
+ /// crucial for (backward) compatibility.
+ /// @param timeout the timeout in seconds for script execution.
+ /// The default value for this (i.e. when no
+ /// ScriptLimits tag is present) is documented to be
+ /// 15 to 20 seconds, depending on platform.
+ void setScriptLimits(boost::uint16_t recursion, boost::uint16_t timeout);
+
+ /// Get the current global recursion limit for this movie: it can
+ /// be changed by loaded movies.
+ boost::uint16_t getRecursionLimit() const
+ {
+ return _recursionLimit;
+ }
+
+ /// Get the current global script timeout limit for this movie: it
+ /// can be changed by loaded movies.
+ boost::uint16_t getTimeoutLimit() const
+ {
+ return _timeoutLimit;
+ }
+
#ifdef USE_SWFTREE
typedef std::pair<std::string, std::string> StringPair;
void getMovieInfo(tree<StringPair>& tr, tree<StringPair>::iterator it);
@@ -1020,6 +1051,14 @@
ScaleMode _scaleMode;
DisplayState _displayState;
+
+ // The maximum number of recursions e.g. when finding
+ // 'super', set in the ScriptLimits tag.
+ boost::uint16_t _recursionLimit;
+
+ // The timeout in seconds for script execution, in the
+ // ScriptLimits tag.
+ boost::uint16_t _timeoutLimit;
};
Index: server/swf/ScriptLimitsTag.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf/ScriptLimitsTag.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/swf/ScriptLimitsTag.h 4 Jun 2008 15:14:47 -0000 1.1
+++ server/swf/ScriptLimitsTag.h 4 Jun 2008 19:54:12 -0000 1.2
@@ -52,8 +52,7 @@
tag, recursionLimit, timeoutLimit);
);
-// r.setRecursionLimit(recursionLimit);
-// r.setTimeoutLimit(timeoutLimit);
+ r.setScriptLimits(recursionLimit, timeoutLimit);
}
}
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...,
Benjamin Wolsey <=