CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/11/28 23:18:42
Modified files: . : ChangeLog libbase : jpeg.cpp jpeg.h Log message: Use setjmp/longjmp from custom error handler so to not return control to libjpeg which doesn't expect that and properly throw an exception on first error. Fixes bug #21609. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5001&r2=1.5002 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/jpeg.cpp?cvsroot=gnash&r1=1.20&r2=1.21 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/jpeg.h?cvsroot=gnash&r1=1.8&r2=1.9 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5001 retrieving revision 1.5002 diff -u -b -r1.5001 -r1.5002 --- ChangeLog 28 Nov 2007 22:39:09 -0000 1.5001 +++ ChangeLog 28 Nov 2007 23:18:42 -0000 1.5002 @@ -1,3 +1,10 @@ +2007-11-29 Sandro Santilli <[EMAIL PROTECTED]> + + * libbase/jpeg.{cpp,h}: use setjmp/longjmp from custom error handler + so to not return control to libjpeg which doesn't expect that + and properly throw an exception on first error. + Fixes bug #21609. + 2007-11-28 Rob Savoye <[EMAIL PROTECTED]> * gui/am-frag: Automake include files to make the top level Index: libbase/jpeg.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/jpeg.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -b -r1.20 -r1.21 --- libbase/jpeg.cpp 28 Aug 2007 13:12:38 -0000 1.20 +++ libbase/jpeg.cpp 28 Nov 2007 23:18:42 -0000 1.21 @@ -16,6 +16,8 @@ #include <cstdio> extern "C" { + +// do we reall want to undefine HAVE_STDLIB_H here ?? #undef HAVE_STDLIB_H #include <jpeglib.h> } @@ -340,6 +342,13 @@ m_cinfo.err = &m_jerr; m_cinfo.client_data = this; + if ( setjmp(_jmpBuf) ) + { + std::stringstream ss; + ss << "Internal jpeg error: " << _errorOccurred; + throw gnash::ParserException(ss.str()); + } + // Initialize decompression object. jpeg_create_decompress(&m_cinfo); @@ -372,6 +381,13 @@ m_cinfo.err = &m_jerr; m_cinfo.client_data = this; + if ( setjmp(_jmpBuf) ) + { + std::stringstream ss; + ss << "Internal jpeg error: " << _errorOccurred; + throw gnash::ParserException(ss.str()); + } + // Initialize decompression object. jpeg_create_decompress(&m_cinfo); @@ -398,7 +414,9 @@ if ( _errorOccurred ) { - throw gnash::ParserException("errors during JPEG header parsing"); + std::stringstream ss; + ss << "Internal jpeg error: " << _errorOccurred; + throw gnash::ParserException(ss.str()); } // Don't start reading any image data! @@ -468,14 +486,18 @@ if ( _errorOccurred ) { - throw gnash::ParserException("errors during JPEG header parsing"); + std::stringstream ss; + ss << "Internal jpeg error during header parsing: " << _errorOccurred; + throw gnash::ParserException(ss.str()); } jpeg_start_decompress(&m_cinfo); if ( _errorOccurred ) { - throw gnash::ParserException("errors during JPEG decompression"); + std::stringstream ss; + ss << "Internal jpeg error during decompression: " << _errorOccurred; + throw gnash::ParserException(ss.str()); } m_compressor_opened = true; @@ -611,16 +633,28 @@ static void jpeg_error_exit(j_common_ptr cinfo) { +#if 0 // will be printed by errorOccurred() IF_VERBOSE_MALFORMED_SWF( gnash::log_swferror(_("Internal jpeg error: %s"), cinfo->err->jpeg_message_table[cinfo->err->msg_code]); ); +#endif // Set a flag to stop parsing input* in = static_cast<input*>(cinfo->client_data); - in->errorOccurred(); + + in->errorOccurred(cinfo->err->jpeg_message_table[cinfo->err->msg_code]); + + //log_error("failing to abort jpeg parser here (would need a long-jump call)"); } +void +input::errorOccurred(const char* msg) +{ + gnash::log_debug("Long jump: banzaaaaaai!"); + _errorOccurred = msg; + longjmp(_jmpBuf, 1); +} /*static*/ Index: libbase/jpeg.h =================================================================== RCS file: /sources/gnash/gnash/libbase/jpeg.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- libbase/jpeg.h 28 Aug 2007 13:12:38 -0000 1.8 +++ libbase/jpeg.h 28 Nov 2007 23:18:42 -0000 1.9 @@ -16,6 +16,8 @@ struct jpeg_compress_struct; class tu_file; +#include <setjmp.h> // for jmp_buf + /// Wrapper for jpeg file operations. // @@ -31,7 +33,7 @@ input() : - _errorOccurred(false) + _errorOccurred(0) {} virtual ~input() {} @@ -89,10 +91,7 @@ virtual int get_width() const = 0; virtual void read_scanline(unsigned char* rgb_data) = 0; - void errorOccurred() - { - _errorOccurred = true; - } + void errorOccurred(const char* msg); protected: @@ -100,7 +99,9 @@ /// invoked by jpeg lib. Will be later used to throw /// a ParserException. /// - bool _errorOccurred; + const char* _errorOccurred; + + jmp_buf _jmpBuf; }; _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit