Skip to content

Commit

Permalink
Disable msg_code use in fuzzing mode
Browse files Browse the repository at this point in the history
bug:oss-fuzz:70102
bug:oss-fuzz:70112
Change-Id: I519c991c784bccb4bbaec622281f81015ab479a4
  • Loading branch information
vrabaud committed Jul 10, 2024
1 parent 41a5e58 commit 4838611
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions imageio/jpegdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,19 @@ struct my_error_mgr {
};

static void my_error_exit(j_common_ptr dinfo) {
// The following code is disabled in fuzzing mode because:
// - the logs can be flooded due to invalid JPEG files
// - msg_code is wrongfully seen as uninitialized by msan when the libjpeg
// dependency is not built with sanitizers enabled
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
struct my_error_mgr* myerr = (struct my_error_mgr*)dinfo->err;
const int msg_code = myerr->pub.msg_code;
fprintf(stderr, "libjpeg error: ");
dinfo->err->output_message(dinfo);
if (msg_code == JERR_INPUT_EOF || msg_code == JERR_FILE_READ) {
fprintf(stderr, "`jpegtran -copy all` MAY be able to process this file.\n");
}
#endif
longjmp(myerr->setjmp_buffer, 1);
}

Expand Down

0 comments on commit 4838611

Please sign in to comment.