Disable msg_code use in fuzzing mode

bug:oss-fuzz:70102
bug:oss-fuzz:70112
Change-Id: I519c991c784bccb4bbaec622281f81015ab479a4
This commit is contained in:
Vincent Rabaud 2024-07-08 15:00:45 +02:00
parent 41a5e582c2
commit 4838611f91

View File

@ -205,6 +205,11 @@ 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: ");
@ -212,6 +217,7 @@ static void my_error_exit(j_common_ptr 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);
}