gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libamf/sol.cpp server/asobj/Sha...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libamf/sol.cpp server/asobj/Sha...
Date: Wed, 13 Feb 2008 14:02:48 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/02/13 14:02:48

Modified files:
        .              : ChangeLog 
        libamf         : sol.cpp 
        server/asobj   : SharedObject.cpp 

Log message:
        fix intermediate directories creation, while still failing if the
        SOLSafeDir doesn't exist.  Fixes one of the bugs in #22013.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5635&r2=1.5636
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/sol.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SharedObject.cpp?cvsroot=gnash&r1=1.34&r2=1.35

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5635
retrieving revision 1.5636
diff -u -b -r1.5635 -r1.5636
--- ChangeLog   13 Feb 2008 13:55:02 -0000      1.5635
+++ ChangeLog   13 Feb 2008 14:02:47 -0000      1.5636
@@ -1,3 +1,9 @@
+2008-02-13 Sandro Santilli <address@hidden>
+
+       * server/asobj/SharedObject.cpp: fix intermediate directories
+         creation, while still failing if the SOLSafeDir doesn't exist.
+         Fixes one of the bugs in #22013.
+
 2008-02-13 Benjamin Wolsey <address@hidden>
 
        * testsuite/misc-ming.all/PrototypeEventListeners.as: test mouse

Index: libamf/sol.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/sol.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- libamf/sol.cpp      13 Feb 2008 13:29:22 -0000      1.21
+++ libamf/sol.cpp      13 Feb 2008 14:02:47 -0000      1.22
@@ -203,7 +203,6 @@
 SOL::writeFile(const string &filespec, const string &name)
 {
 //    GNASH_REPORT_FUNCTION;
-       log_debug("Opening file %s in binary mode (for writing?reading?what?)", 
filespec.c_str());
     ofstream ofs(filespec.c_str(), ios::binary);
     if ( ! ofs )
     {

Index: server/asobj/SharedObject.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SharedObject.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/asobj/SharedObject.cpp       13 Feb 2008 13:29:22 -0000      1.34
+++ server/asobj/SharedObject.cpp       13 Feb 2008 14:02:47 -0000      1.35
@@ -233,6 +233,7 @@
         log_error("writing SharedObject file to %s", newspec.c_str());
         return as_value(false);
     }
+    log_security("SharedObject '%s' written to filesystem.", newspec.c_str());
     return as_value(true); // TODO: check expected return type from 
SharedObject.flush
 #else
     return as_value(false);
@@ -287,6 +288,14 @@
         newspec = "/tmp/";
     }
     
+    // TODO: check if the base dir exists here, or skip the flush
+    struct stat statbuf;
+    if ( -1 == stat(newspec.c_str(), &statbuf) )
+    {
+       log_error("Invalid SOL safe dir %s: %s", newspec.c_str(), 
strerror(errno));
+        return as_value(false);
+    }
+    
     // Which URL we should use here is under research.
     // The reference player uses the URL from which definition
     // of the call to SharedObject.getLocal was parsed.
@@ -318,6 +327,8 @@
     
     // Get the path part
     string swfile = url.path();
+       // TODO: if the original url was a relative one, the pp uses just
+       // the relative portion rather then the resolved absolute path !
     
     if ( rcfile.getSOLLocalDomain() && domain != "localhost") 
     {
@@ -343,44 +354,40 @@
         newspec += "/";
     }
         
-    if (obj->getFilespec().find("/", 0) != string::npos) {
+    //log_debug("newspec before adding obj's filespec: %s", newspec.c_str());
+    newspec += obj->getFilespec();
+    obj->setFilespec(newspec);
+        
+    if (newspec.find("/", 0) != string::npos) {
         typedef tokenizer<char_separator<char> > Tok;
         char_separator<char> sep("/");
-        Tok t(obj->getFilespec(), sep);
+        Tok t(newspec, sep);
         Tok::iterator tit;
-        string newdir = newspec;
+        string newdir = "/";
         for(tit=t.begin(); tit!=t.end();++tit){
-            cout << *tit << "\n";
+            //cout << *tit << "\n";
             newdir += *tit;
-            cout << "Dir: " << newdir << " to be created" << endl;
             if (newdir.find("..", 0) != string::npos) {
+               log_error("Invalid SharedObject path (contains '..'): %s", 
newspec.c_str());
                 return as_value(false);
             }
             // Don't try to create a directory of the .sol file name!
-            if (newdir.rfind(".sol", newdir.size()) == string::npos) {
+            // TODO: don't fail if the movie url has a component ending with 
.sol (eh...)
+            //
+            if (newdir.rfind(".sol") != (newdir.size()-4)) {
                 int ret = mkdir(newdir.c_str(), S_IRUSR|S_IWUSR|S_IXUSR);
                 if ((errno != EEXIST) && (ret != 0)) {
                     log_error("Couldn't create directory for .sol files: 
%s\n\t%s",
                               newdir.c_str(), strerror(errno));
                     return as_value(false);
                 }
-            }
+            } // else log_debug("newdir %s ends with .sol", newdir.c_str());
             newdir += "/";
         }
-    } else log_debug("no slash in filespec %s", obj->getFilespec().c_str());
-    
-//     int ret = mkdir(newspec.c_str(), S_IRUSR|S_IWUSR|S_IXUSR);
-//     if ((errno != EEXIST) && (ret != 0)) {
-//         log_error("Couldn't create directory for .sol files: %s\n\t%s",
-//                   newspec.c_str(), strerror(errno));
-//         return as_value(false);
-//     }
-    
-    newspec += obj->getFilespec();
-    obj->setFilespec(newspec);
-    log_security("Opening SharedObject file: %s", newspec.c_str());
+    } // else log_debug("no slash in filespec %s", obj->getFilespec().c_str());
 
     SOL sol;
+    log_security("Opening SharedObject file: %s", newspec.c_str());
     if (sol.readFile(newspec) == false) {
         log_security("empty or non-existing SOL file \"%s\", will be created 
on flush/exit", newspec.c_str());
         return as_value(obj.get());




reply via email to

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