diff --git a/ChangeLog.md b/ChangeLog.md index 14aeee82..ba400d92 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 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) ================== diff --git a/turbojpeg.c b/turbojpeg.c index a41e8dfd..90a9ce6a 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -65,6 +65,12 @@ struct my_error_mgr { }; 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) { 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.emit_message = this->jerr.pub.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 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.emit_message = this->jerr.pub.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 we get here, the JPEG code has signaled an error. */