TurboJPEG: Handle JERR_BMP*,JERR_PPM* error codes
... in tjLoadImage()/tjSaveImage(). These error codes require an add-on message table, and if it isn't initialized, then format_message() produces "Bogus message code XXXX" instead.
This commit is contained in:
@@ -25,6 +25,11 @@ the underlying library, and because it did not involve any out-of-bounds reads
|
|||||||
or other exploitable behaviors, it was not believed to represent a security
|
or other exploitable behaviors, it was not believed to represent a security
|
||||||
threat.
|
threat.
|
||||||
|
|
||||||
|
3. Fixed an issue whereby the `tjLoadImage()` and `tjSaveImage()` functions
|
||||||
|
would produce a "Bogus message code" error message if the underlying bitmap and
|
||||||
|
PPM readers/writers threw an error that was specific to the readers/writers
|
||||||
|
(as opposed to a general libjpeg API error.)
|
||||||
|
|
||||||
|
|
||||||
1.5.90 (2.0 beta1)
|
1.5.90 (2.0 beta1)
|
||||||
==================
|
==================
|
||||||
|
|||||||
12
turbojpeg.c
12
turbojpeg.c
@@ -65,6 +65,12 @@ struct my_error_mgr {
|
|||||||
};
|
};
|
||||||
typedef struct my_error_mgr *my_error_ptr;
|
typedef struct my_error_mgr *my_error_ptr;
|
||||||
|
|
||||||
|
#define JMESSAGE(code, string) string,
|
||||||
|
static const char *turbojpeg_message_table[] = {
|
||||||
|
#include "cderror.h"
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
static void my_error_exit(j_common_ptr cinfo)
|
static void my_error_exit(j_common_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_error_ptr myerr = (my_error_ptr)cinfo->err;
|
my_error_ptr myerr = (my_error_ptr)cinfo->err;
|
||||||
@@ -431,6 +437,9 @@ static tjhandle _tjInitCompress(tjinstance *this)
|
|||||||
this->jerr.pub.output_message = my_output_message;
|
this->jerr.pub.output_message = my_output_message;
|
||||||
this->jerr.emit_message = this->jerr.pub.emit_message;
|
this->jerr.emit_message = this->jerr.pub.emit_message;
|
||||||
this->jerr.pub.emit_message = my_emit_message;
|
this->jerr.pub.emit_message = my_emit_message;
|
||||||
|
this->jerr.pub.addon_message_table = turbojpeg_message_table;
|
||||||
|
this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
|
||||||
|
this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
|
||||||
|
|
||||||
if (setjmp(this->jerr.setjmp_buffer)) {
|
if (setjmp(this->jerr.setjmp_buffer)) {
|
||||||
/* If we get here, the JPEG code has signaled an error. */
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
@@ -1087,6 +1096,9 @@ static tjhandle _tjInitDecompress(tjinstance *this)
|
|||||||
this->jerr.pub.output_message = my_output_message;
|
this->jerr.pub.output_message = my_output_message;
|
||||||
this->jerr.emit_message = this->jerr.pub.emit_message;
|
this->jerr.emit_message = this->jerr.pub.emit_message;
|
||||||
this->jerr.pub.emit_message = my_emit_message;
|
this->jerr.pub.emit_message = my_emit_message;
|
||||||
|
this->jerr.pub.addon_message_table = turbojpeg_message_table;
|
||||||
|
this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
|
||||||
|
this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
|
||||||
|
|
||||||
if (setjmp(this->jerr.setjmp_buffer)) {
|
if (setjmp(this->jerr.setjmp_buffer)) {
|
||||||
/* If we get here, the JPEG code has signaled an error. */
|
/* If we get here, the JPEG code has signaled an error. */
|
||||||
|
|||||||
Reference in New Issue
Block a user