gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libbase/jpeg.cpp libbase/jpeg.h...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libbase/jpeg.cpp libbase/jpeg.h...
Date: Fri, 14 Dec 2007 12:35:17 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/12/14 12:35:17

Modified files:
        .              : ChangeLog 
        libbase        : jpeg.cpp jpeg.h 
        server/swf     : tag_loaders.cpp 

Log message:
        Still initialize a jpeg input when JPEGTABLES tag is 0-sized

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5171&r2=1.5172
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/jpeg.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/jpeg.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.170&r2=1.171

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5171
retrieving revision 1.5172
diff -u -b -r1.5171 -r1.5172
--- ChangeLog   14 Dec 2007 11:50:06 -0000      1.5171
+++ ChangeLog   14 Dec 2007 12:35:16 -0000      1.5172
@@ -1,5 +1,13 @@
 2007-12-14 Sandro Santilli <address@hidden>
 
+       * libbase/jpeg.{cpp,h}: get a max header bytes parameter to limit
+         input stream. Currently only used to skip a 0-sized header
+         while still allowing further parsing of DEFINEBITS tag.
+       * server/swf/tag_loaders.cpp: pass max header bytes when parsing
+         JPEGTABLES. Fixes the 0-length JPEGTABLES tag (missing a testcase).
+
+2007-12-14 Sandro Santilli <address@hidden>
+
        * testsuite/movies.all/Makefile.am: don't abort on failure.
          
 2007-12-14 Benjamin Wolsey <address@hidden>

Index: libbase/jpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/jpeg.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- libbase/jpeg.cpp    28 Nov 2007 23:18:42 -0000      1.21
+++ libbase/jpeg.cpp    14 Dec 2007 12:35:17 -0000      1.22
@@ -85,6 +85,7 @@
                {
                        rw_source_tu_file*      src = (rw_source_tu_file*) 
cinfo->src;
 
+                       // TODO: limit read as requested by caller
                        size_t  bytes_read = 
src->m_in_stream->read_bytes(src->m_buffer, IO_BUF_SIZE);
 
                        if (bytes_read <= 0) {
@@ -373,7 +374,7 @@
                ///     If true, we take ownership of the input stream. 
                ///
                input_tu_file(SWF_DEFINE_BITS_JPEG2_HEADER_ONLY /* e */, 
tu_file* in,
-                               bool takeOwnership=false)
+                               unsigned int maxHeaderBytes, bool 
takeOwnership=false)
                        :
                        m_compressor_opened(false)
                {
@@ -393,7 +394,12 @@
 
                        rw_source_tu_file::setup(&m_cinfo, in, takeOwnership);
 
+                       if ( maxHeaderBytes )
+                       {
+                               unsigned long startPos = in->get_position();
+
                        // Read the encoding tables.
+                               // TODO: how to limit reads ?
                        int ret = jpeg_read_header(&m_cinfo, FALSE);
                        switch (ret)
                        {
@@ -419,6 +425,13 @@
                                throw gnash::ParserException(ss.str());
                        }
 
+                               unsigned long endPos = in->get_position();
+                               if ( endPos - startPos > maxHeaderBytes )
+                               {
+                                       gnash::log_error("Reading of jpeg 
headers went past requested maxHeaderBytes");
+                               }
+                       }
+
                        // Don't start reading any image data!
                        // App does that manually using start_image.
                }
@@ -667,10 +680,10 @@
 
 /*static*/
 input*
-input::create_swf_jpeg2_header_only(tu_file* in, bool takeOwnership)
+input::create_swf_jpeg2_header_only(tu_file* in, unsigned int maxHeaderBytes, 
bool takeOwnership)
 {
        using tu_file_wrappers::input_tu_file;
-       input* ret = new input_tu_file(input_tu_file::SWF_JPEG2_HEADER_ONLY, 
in, takeOwnership);
+       input* ret = new input_tu_file(input_tu_file::SWF_JPEG2_HEADER_ONLY, 
in, maxHeaderBytes, takeOwnership);
        return ret;
 }
 

Index: libbase/jpeg.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/jpeg.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libbase/jpeg.h      28 Nov 2007 23:18:42 -0000      1.9
+++ libbase/jpeg.h      14 Dec 2007 12:35:17 -0000      1.10
@@ -69,6 +69,9 @@
                ///     The tu_file to use for input. Ownership specified
                ///     by last arg.
                ///
+               /// @param maxHeaderBytes
+               ///     Max number of bytes to read from input for header.
+               ///
                /// @param takeOwnership
                ///     If false, ownership of the stream 
                ///     is left to caller, otherwise we take it.
@@ -79,7 +82,7 @@
                /// @return NULL on error
                ///
                DSOEXPORT static input* create_swf_jpeg2_header_only(tu_file* 
in,
-                               bool takeOwnership=false);
+                               unsigned int maxHeaderBytes, bool 
takeOwnership=false);
 
                /// Discard existing bytes in our buffer.
                virtual void    discard_partial_buffer() = 0;

Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -b -r1.170 -r1.171
--- server/swf/tag_loaders.cpp  13 Dec 2007 11:40:13 -0000      1.170
+++ server/swf/tag_loaders.cpp  14 Dec 2007 12:35:17 -0000      1.171
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: tag_loaders.cpp,v 1.170 2007/12/13 11:40:13 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.171 2007/12/14 12:35:17 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -233,12 +233,13 @@
     unsigned long currPos = in->get_position();
     unsigned long endPos = in->get_tag_end_position();
 
-    if ( endPos == currPos )
+    assert(endPos >= currPos);
+
+    unsigned int jpegHeaderSize = endPos-currPos;
+
+    if ( ! jpegHeaderSize )
     {
-        IF_VERBOSE_MALFORMED_SWF(
-        log_swferror(_("No bytes to read in JPEGTABLES tag at offset %lu"), 
currPos);
-        );
-        return;
+        log_debug(_("No bytes to read in JPEGTABLES tag at offset %lu"), 
currPos);
     }
 
     std::auto_ptr<jpeg::input> j_in;
@@ -258,7 +259,7 @@
        //
         std::auto_ptr<tu_file> ad( StreamAdapter::getFile(*in, 
std::numeric_limits<unsigned long>::max()) );
         //  transfer ownerhip to the jpeg::input
-        j_in.reset(jpeg::input::create_swf_jpeg2_header_only(ad.release(), 
true));
+        j_in.reset(jpeg::input::create_swf_jpeg2_header_only(ad.release(), 
jpegHeaderSize, true));
 
     }
     catch (std::exception& e)
@@ -269,7 +270,7 @@
         return;
     }
 
-    log_debug("Setting jpeg loader to %p", j_in.get());
+    log_debug("Setting jpeg loader to %p", (void*)j_in.get());
     m->set_jpeg_loader(j_in);
 }
 




reply via email to

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