gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_environment.cpp tests...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_environment.cpp tests...
Date: Thu, 17 Jan 2008 22:09:13 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/01/17 22:09:13

Modified files:
        .              : ChangeLog 
        server         : as_environment.cpp 
        testsuite/actionscript.all: getvariable.as 
        testsuite/misc-ming.all: callFunction_test.c 
        testsuite/swfdec: PASSING 

Log message:
        add more corner case handlign for get_variable and find_object. The code
        keeps getting uglier, but this change gets no unexpected failure while
        gets unexpected successes in a few places:

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5427&r2=1.5428
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.119&r2=1.120
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/getvariable.as?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/callFunction_test.c?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.85&r2=1.86

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5427
retrieving revision 1.5428
diff -u -b -r1.5427 -r1.5428
--- ChangeLog   17 Jan 2008 20:36:14 -0000      1.5427
+++ ChangeLog   17 Jan 2008 22:09:12 -0000      1.5428
@@ -1,5 +1,15 @@
 2008-01-17 Sandro Santilli <address@hidden>
 
+       * server/as_environment.cpp: add more corner case handlign 
+         for get_variable and find_object. The code keeps getting
+         uglier, but this change gets no unexpected failure while
+         gets unexpected successes in a few places:
+       * testsuite/actionscript.all/getvariable.as: successes.
+       * testsuite/misc-ming.all/callFunction_test.c: successes
+       * testsuite/swfdec/PASSING: successes.
+
+2008-01-17 Sandro Santilli <address@hidden>
+
        * libbase/tu_file.cpp: fix memory buffer adapter, applying
          an unchecked but blindly trusting patch sent on the gameswf
          list by Eli Curtz.

Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -b -r1.119 -r1.120
--- server/as_environment.cpp   10 Jan 2008 17:34:45 -0000      1.119
+++ server/as_environment.cpp   17 Jan 2008 22:09:12 -0000      1.120
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: as_environment.cpp,v 1.119 2008/01/10 17:34:45 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.120 2008/01/17 22:09:12 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -97,7 +97,7 @@
     else
     {
        // TODO: have this checked by parse_path as an optimization 
-       if ( varname.find_first_of('/') != string::npos )
+       if ( varname.find_first_of('/') != string::npos && 
varname.find_first_of(':') == string::npos )
        {
                // Consider it all a path ...
                as_object* target = find_object(varname, &scopeStack); 
@@ -119,13 +119,42 @@
        return get_variable(varname, empty_scopeStack);
 }
 
+static bool validRawVariableName(const std::string& varname)
+{
+       // check raw variable name validity
+       const char* ptr = varname.c_str();
+       for (;;)
+       {
+               ptr = strchr(ptr, ':');
+               if ( ! ptr ) break;
+
+               int num=1;
+               while (*(++ptr) == ':') ++num;
+               if (num>2) 
+               {
+                       //log_debug("Invalid raw variable name...");
+                       return false;
+               }
+       } 
+
+       return true;
+}
+
 as_value
 as_environment::get_variable_raw(
     const std::string& varname,
     const ScopeStack& scopeStack, as_object** retTarget) const
     // varname must be a plain variable name; no path parsing.
 {
-    assert(strchr(varname.c_str(), ':') == NULL);
+    //assert(strchr(varname.c_str(), ':') == NULL);
+
+       if ( ! validRawVariableName(varname) )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("Won't get invalid raw variable name: %s"), 
varname.c_str());
+               );
+               return as_value();
+       }
 
     as_value    val;
 
@@ -305,6 +334,14 @@
     const ScopeStack& scopeStack)
 {
 
+       if ( ! validRawVariableName(varname) )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("Won't set invalid raw variable name: %s"), 
varname.c_str());
+               );
+               return;
+       }
+
     VM& vm = VM::get();
     int swfVersion = vm.getSWFVersion();
     string_table& st = vm.getStringTable();
@@ -322,15 +359,6 @@
             if (obj && obj->update_member(varkey, val).first )
             {
                return;
-#if 0
-               Property* prop = obj->findUpdatableProperty(varkey);
-               if ( prop )
-               {
-                       //prop->setValue(*obj, val);
-                       obj->set_member(varkey, val);
-                       return;
-               }
-#endif
             }
         }
 
@@ -350,15 +378,6 @@
             if (obj && obj->update_member(varkey, val).first )
             {
                return;
-#if 0
-               Property* prop = obj->findUpdatableProperty(varkey);
-               if ( prop )
-               {
-                       //prop->setValue(*obj, val);
-                       obj->set_member(varkey, val);
-                       return;
-               }
-#endif
             }
         }
 
@@ -420,45 +439,50 @@
 
 /* public static */
 bool
-as_environment::parse_path(const std::string& var_path,
+as_environment::parse_path(const std::string& var_path_in,
                std::string& path, std::string& var)
 {
-//log_msg(_("parse_path(%s)"), var_path.c_str());
-    // Search for colon.
-    int        colon_index = 0;
-    int        var_path_length = var_path.length();
-    for ( ; colon_index < var_path_length; colon_index++) {
-       if (var_path[colon_index] == ':') {
-           // Found it.
-           break;
-       }
-    }
+#ifdef DEBUG_TARGET_FINDING 
+       log_debug("parse_path(%s)", var_path_in.c_str());
+#endif
     
-    if (colon_index >= var_path_length)        {
-//log_debug(_(" no colon in path"));
-       // No colon.  Is there a '.'?  Find the last
-       // one, if any.
-       for (colon_index = var_path_length - 1; colon_index >= 0; 
colon_index--) {
-           if (var_path[colon_index] == '.') {
-               // Found it.
-               break;
-           }
-       }
-       if (colon_index < 0) {
-//log_debug(_(" no dot in path"));
+       size_t lastDotOrColon = var_path_in.find_last_of(":.");
+       if ( lastDotOrColon == string::npos ) return false;
+
+       string thePath, theVar;
+
+       thePath.assign(var_path_in, 0, lastDotOrColon);
+       theVar.assign(var_path_in, lastDotOrColon+1, var_path_in.length());
+
+#ifdef DEBUG_TARGET_FINDING 
+       log_debug("path: %s, var: %s", thePath.c_str(), theVar.c_str());
+#endif
+
+       if ( thePath.empty() ) return false;
+
+       // this check should be performed by callers (getvariable/setvariable 
in particular)
+       size_t pathlen = thePath.length();
+       size_t i = pathlen-1;
+       size_t contiguoscommas = 0;
+       while ( i && thePath[i--] == ':' )
+       {
+               if ( ++contiguoscommas > 1 )
+               {
+#ifdef DEBUG_TARGET_FINDING 
+                       log_debug("path '%s' ends with too many colon chars, 
not considering a path", thePath.c_str());
+#endif
            return false;
        }
     }
     
-    // Make the subparts.
-    
-    // Var
-    var = &var_path[colon_index + 1];
+#ifdef DEBUG_TARGET_FINDING 
+       log_debug("contiguoscommas: %d", contiguoscommas);
+#endif
     
-    // Path
-    path.assign(var_path, 0, colon_index);
+       //if ( var.empty() ) return false;
     
-//log_debug(_(" path=%s var=%s"), path.c_str(), var.c_str());
+       path = thePath;
+       var = theVar;
 
     return true;
 }

Index: testsuite/actionscript.all/getvariable.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/getvariable.as,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- testsuite/actionscript.all/getvariable.as   17 Jan 2008 18:34:36 -0000      
1.22
+++ testsuite/actionscript.all/getvariable.as   17 Jan 2008 22:09:12 -0000      
1.23
@@ -19,7 +19,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: getvariable.as,v 1.22 2008/01/17 18:34:36 strk Exp $";
+rcsid="$Id: getvariable.as,v 1.23 2008/01/17 22:09:12 strk Exp $";
 
 #include "check.as"
 
@@ -315,7 +315,7 @@
         push 'yes4'
         setvariable
 };
-xcheck_equals(obj.variable_in_object, 'yes4');
+check_equals(obj.variable_in_object, 'yes4');
 
 // NOTE: 'obj:::variable_in_object' is invalid, while
 //       'obj::variable_in_object' is valid - AARagagag
@@ -324,7 +324,7 @@
         push 'yes5'
         setvariable
 };
-xcheck_equals(obj.variable_in_object, 'yes4');
+check_equals(obj.variable_in_object, 'yes4');
 
 //---------------------------------------------------------------------
 // Check 'mc1:variable_in_object' access 
@@ -532,7 +532,7 @@
        getvariable
         setvariable
 };
-xcheck_equals(objmemb, 4);
+check_equals(objmemb, 4);
 
 //-----------------------------------------------------------------------
 // Check '::obj::member' access 
@@ -545,7 +545,7 @@
        getvariable
         setvariable
 };
-xcheck_equals(objmemb, 4.4);
+check_equals(objmemb, 4.4);
 
 //-----------------------------------------------------------------------
 // Check '::obj.member' access 
@@ -558,7 +558,7 @@
        getvariable
         setvariable
 };
-xcheck_equals(objmemb, 4);
+check_equals(objmemb, 4);
 
 //-----------------------------------------------------------------------
 // Check 'this/:member' access  (and deletion)

Index: testsuite/misc-ming.all/callFunction_test.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/callFunction_test.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- testsuite/misc-ming.all/callFunction_test.c 14 Nov 2007 22:16:05 -0000      
1.5
+++ testsuite/misc-ming.all/callFunction_test.c 17 Jan 2008 22:09:13 -0000      
1.6
@@ -151,7 +151,7 @@
   check_equals(mo, "_root.x5", "1");
   check_equals(mo, "_root.x6", "_root.mc1");
   check_equals(mo, "_root.x7", "1");
-  xcheck_equals(mo, "_root.x8", "1");
+  check_equals(mo, "_root.x8", "1");
   
   add_actions(mo, " _root.totals(); stop(); ");
   SWFMovie_nextFrame(mo); 

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- testsuite/swfdec/PASSING    15 Jan 2008 09:35:11 -0000      1.85
+++ testsuite/swfdec/PASSING    17 Jan 2008 22:09:13 -0000      1.86
@@ -226,6 +226,7 @@
 getsetproperty-target-6.swf:cd70c0eac0ac31400859178f7d877fe1
 getsetproperty-target-7.swf:d7d730794e6318c1b69a7e946cb2fedd
 getsetproperty-target-8.swf:b558d97e246e9ed2b90969d96f3e0fcc
+getvariable-delimiters-5.swf:4d0d118364bf68f0cb3b24848b6eaff7
 getvariable-dotdot-5.swf:68529abcc9f149593f50dfacb3f8656e
 getvariable-dotdot-6.swf:becc7079e65bcf47fe2ab0293bbc2c29
 getvariable-dotdot-7.swf:efa5597fe3e61764b6ee937f87d8cf1b
@@ -236,6 +237,10 @@
 getvariable-slashpath-7.swf:499213312255eba3746c4ff6b7b4782d
 getvariable-slashpath-8.swf:19df043ceda9c1db9efbd185bb5ae2cb
 getvariable-special-5.swf:4baac55533a4cc67a3419dafb97cc888
+getvariable-various-5.swf:a79d72c6daacf8d745aba5c194edf998
+getvariable-various-6.swf:1488b4d8e200bcad7027ae618a6c08d2
+getvariable-various-7.swf:d8a5c5449de5bcc427877c655033811e
+getvariable-various-8.swf:7211050a012850e666db0fa4032abc72
 glow-filter-properties-5.swf:10d87d4cbd9c1f4c41a817f67cf3f530
 glow-filter-properties-5.swf:b3d05908aaa98c7115ec1727d695a16a
 goto1.swf:6f35a27cb3aee7f282eccb3b16290c70
@@ -329,6 +334,9 @@
 netstream-fscommand-7.swf:ec9312835ba2e8a7347252bcaef7db0b
 netstream-fscommand-8.swf:38f05e4f8d3a4e2faae0ef9e18e7754b
 newobject-paths-5.swf:7fe3f8dd1f89838358ba5e92417ac888
+newobject-paths-6.swf:e2e207b7b6966fdffd3a0017cdbf2f1c
+newobject-paths-7.swf:e8af4c2cd51e1b3c5e7ab3121386d0ba
+newobject-paths-8.swf:fc8407413a00bf2e41e27db7e7ec8c9f
 object-ispropertyenumerable-5.swf:775ef8e8b0ec09d72adec0bdf64b282e
 object-math-5.swf:2d509f7b6e94776a2208fcbec80b7a67
 object-math-6.swf:bdf73b4bfb144113a80ff78a282558d7




reply via email to

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