Skip to content

Commit

Permalink
More jpeglib unpoisoning
Browse files Browse the repository at this point in the history
from #3610 of libjxl
  • Loading branch information
mo271 committed Nov 5, 2024
1 parent 5ea116a commit b4a8ec6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/jpegli/libjpeg_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ void DecodeWithLibjpeg(const CompressParams& jparams,
if (dparams.output_mode == COEFFICIENTS) {
jvirt_barray_ptr* coef_arrays = jpeg_read_coefficients(cinfo);
JXL_CHECK(coef_arrays != nullptr);
jxl::msan::UnpoisonMemory(coef_arrays,
cinfo->num_components * sizeof(jvirt_barray_ptr));
CopyCoefficients(cinfo, coef_arrays, output);
} else {
JXL_CHECK(jpeg_start_decompress(cinfo));
Expand Down Expand Up @@ -203,6 +205,8 @@ void DecodeAllScansWithLibjpeg(const CompressParams& jparams,
if (dparams.output_mode == COEFFICIENTS) {
jvirt_barray_ptr* coef_arrays = jpeg_read_coefficients(&cinfo);
JXL_CHECK(coef_arrays != nullptr);
jxl::msan::UnpoisonMemory(
coef_arrays, cinfo.num_components * sizeof(jvirt_barray_ptr));
CopyCoefficients(&cinfo, coef_arrays, &output_progression->back());
}
}
Expand Down Expand Up @@ -242,6 +246,7 @@ size_t DecodeWithLibjpeg(const CompressParams& jparams,
}
jpeg_mem_src(&cinfo, compressed, len);
DecodeWithLibjpeg(jparams, dparams, &cinfo, output);
jxl::msan::UnpoisonMemory(cinfo.src, sizeof(jpeg_source_mgr));
bytes_read = len - cinfo.src->bytes_in_buffer;
return true;
};
Expand Down

0 comments on commit b4a8ec6

Please sign in to comment.