gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/swf/tag_loaders.cpp


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/swf/tag_loaders.cpp
Date: Wed, 01 Aug 2007 21:31:58 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/08/01 21:31:58

Modified files:
        .              : ChangeLog 
        server/swf     : tag_loaders.cpp 

Log message:
                * server/swf/tag_loaders.cpp: completely remove the bogus 
assertion
                  about the required input bytes in relation to the number of 
samples.
                  Rather, add more ensureBytes() uses, closer to where the data 
is
                  actually read from the stream.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3904&r2=1.3905
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.119&r2=1.120

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3904
retrieving revision 1.3905
diff -u -b -r1.3904 -r1.3905
--- ChangeLog   1 Aug 2007 21:03:12 -0000       1.3904
+++ ChangeLog   1 Aug 2007 21:31:57 -0000       1.3905
@@ -1,5 +1,12 @@
 2007-08-01 Sandro Santilli <address@hidden>
 
+       * server/swf/tag_loaders.cpp: completely remove the bogus assertion
+         about the required input bytes in relation to the number of samples.
+         Rather, add more ensureBytes() uses, closer to where the data is
+         actually read from the stream.
+
+2007-08-01 Sandro Santilli <address@hidden>
+
        * server/swf/tag_loaders.cpp (sound_expand): fix assertion
          checking; added some uses of the new stream::ensureBytes() method;
          add more scoped_array uses.

Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -b -r1.119 -r1.120
--- server/swf/tag_loaders.cpp  1 Aug 2007 21:03:12 -0000       1.119
+++ server/swf/tag_loaders.cpp  1 Aug 2007 21:31:57 -0000       1.120
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: tag_loaders.cpp,v 1.119 2007/08/01 21:03:12 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.120 2007/08/01 21:31:57 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1054,12 +1054,15 @@
 
        sound_handler* handler = get_sound_handler();
 
+       in->ensureBytes(2+1+4); // character id + flags + sample count
+
        uint16_t        character_id = in->read_u16();
 
        sound_handler::format_type      format = (sound_handler::format_type) 
in->read_uint(4);
        int     sample_rate = in->read_uint(2); // multiples of 5512.5
        bool    sample_16bit = in->read_uint(1) ? true : false;
        bool    stereo = in->read_uint(1) ? true : false;
+
        unsigned int    sample_count = in->read_u32();
 
        IF_VERBOSE_PARSE
@@ -1086,17 +1089,6 @@
            unsigned data_bytes; // First it is the amount of data from file,
                        // then the amount allocated at *data (it may grow)
 
-           data_bytes = in->get_tag_end_position() - in->get_position();
-
-           if ( sample_count > data_bytes )
-           {
-               IF_VERBOSE_MALFORMED_SWF(
-                   log_swferror(_("Samples count (%u) exceed the number of 
bytes available in the DefineSound tag containing it (%u)"),
-                       sample_count, data_bytes);
-               );
-               return;
-           }
-
            // sound_expand allocates storage for data[].
            // and modifies 3 parameters: format, data and data_bytes.
            sound_expand(in, format, sample_16bit, stereo, sample_count, data, 
data_bytes);
@@ -1316,7 +1308,6 @@
        bool sample_16bit, bool stereo, unsigned int &sample_count,
        unsigned char* &data, unsigned &data_bytes)
 {
-    assert(sample_count < data_bytes);
 
     // Make sure that an unassigned pointer cannot get through
     data = NULL;
@@ -1337,6 +1328,7 @@
        // Convert to 16-bit host-endian
        if (sample_16bit) {
            // FORMAT_RAW 16-bit is exactly what we want!
+           in->ensureBytes(data_bytes); 
            data = new unsigned char[data_bytes];
            in->read((char *)data, data_bytes);
        } else {
@@ -1362,6 +1354,7 @@
 
        } else {
            // Read 16-bit data into buffer
+           in->ensureBytes(data_bytes); 
            data = new unsigned char[data_bytes];
            in->read((char *)data, data_bytes);
 
@@ -1399,6 +1392,7 @@
 
     case sound_handler::FORMAT_MP3:
        // Decompressed elsewhere
+       in->ensureBytes(data_bytes); 
        data = new unsigned char[data_bytes];
        in->read((char *)data, data_bytes);
        break;
@@ -1406,6 +1400,7 @@
     case sound_handler::FORMAT_NELLYMOSER_8HZ_MONO:
     case sound_handler::FORMAT_NELLYMOSER:
        // One day...
+       in->ensureBytes(data_bytes); 
        in->skip_bytes(data_bytes);
        data = NULL;
        break;
@@ -1561,6 +1556,8 @@
 {
        unsigned total_samples = stereo ? sample_count*2 : sample_count;
 
+       in->ensureBytes(total_samples); 
+
        boost::scoped_array<uint8_t> in_data ( new uint8_t[total_samples] );
        int16_t *out_data = new int16_t[total_samples];
 
@@ -1728,11 +1725,17 @@
        data = reinterpret_cast<unsigned char *>(out_data);
 
        // Read header.
+       in->ensureBytes(2);   // header size
        int     n_bits = in->read_uint(2) + 2;  // 2 to 5 bits
 
+       // 4 is the fixed header for each sample ( 16bit sample id, 6bit 
stepsize_index )
+       // nbits is the number of bits for each sample
+       in->ensureBytes( sample_count * ( 3 + ceil(n_bits/8) ) );
+
        while (sample_count)
        {
                // Read initial sample & index values.
+
                int     sample = in->read_sint(16);
 
                int     stepsize_index = in->read_uint(6);




reply via email to

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