Update libjpeg-turbo to v2.0.90 (2.1 beta1)
Update Chromium's copy of libjpeg-turbo to the latest upstream
release (v2.0.90) and re-apply our local changes documented in
README.chromium.
Cherry-pick two additional changes from upstream to fix bugs found
by fuzzers:
1) https://github.com/libjpeg-turbo/libjpeg-turbo/commit/ccaba5d7894ecfb5a8f11e48d3f86e1f14d5a469
2) https://github.com/libjpeg-turbo/libjpeg-turbo/commit/c7ca521bc85b57d41d3ad4963c13fc0100481084
Significant changes provided by this update:
1) A large performance boost to JPEG encoding due to an improved
Huffman encoding implementation.
2) The complete removal of Arm Neon assembly code. This allows Arm's
control-flow integrity security features (Armv8.3-A Pointer
Authentication and Armv8.5-A Branch Target Identification) to be
switched on with the appropriate compiler flags.
Bug: 922430
Bug: b/135180511
Bug: 919548, 1145581
Change-Id: I319fcdc55b3fd5b219425c07a4e4a03587f4e06d
diff --git a/cdjpeg.c b/cdjpeg.c
index e0e382d..5278c1d 100644
--- a/cdjpeg.c
+++ b/cdjpeg.c
@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2019, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -25,26 +25,37 @@
* Optional progress monitor: display a percent-done figure on stderr.
*/
-#ifdef PROGRESS_REPORT
-
METHODDEF(void)
progress_monitor(j_common_ptr cinfo)
{
cd_progress_ptr prog = (cd_progress_ptr)cinfo->progress;
- int total_passes = prog->pub.total_passes + prog->total_extra_passes;
- int percent_done =
- (int)(prog->pub.pass_counter * 100L / prog->pub.pass_limit);
- if (percent_done != prog->percent_done) {
- prog->percent_done = percent_done;
- if (total_passes > 1) {
- fprintf(stderr, "\rPass %d/%d: %3d%% ",
- prog->pub.completed_passes + prog->completed_extra_passes + 1,
- total_passes, percent_done);
- } else {
- fprintf(stderr, "\r %3d%% ", percent_done);
+ if (prog->max_scans != 0 && cinfo->is_decompressor) {
+ int scan_no = ((j_decompress_ptr)cinfo)->input_scan_number;
+
+ if (scan_no > (int)prog->max_scans) {
+ fprintf(stderr, "Scan number %d exceeds maximum scans (%d)\n", scan_no,
+ prog->max_scans);
+ exit(EXIT_FAILURE);
}
- fflush(stderr);
+ }
+
+ if (prog->report) {
+ int total_passes = prog->pub.total_passes + prog->total_extra_passes;
+ int percent_done =
+ (int)(prog->pub.pass_counter * 100L / prog->pub.pass_limit);
+
+ if (percent_done != prog->percent_done) {
+ prog->percent_done = percent_done;
+ if (total_passes > 1) {
+ fprintf(stderr, "\rPass %d/%d: %3d%% ",
+ prog->pub.completed_passes + prog->completed_extra_passes + 1,
+ total_passes, percent_done);
+ } else {
+ fprintf(stderr, "\r %3d%% ", percent_done);
+ }
+ fflush(stderr);
+ }
}
}
@@ -57,6 +68,8 @@
progress->pub.progress_monitor = progress_monitor;
progress->completed_extra_passes = 0;
progress->total_extra_passes = 0;
+ progress->max_scans = 0;
+ progress->report = FALSE;
progress->percent_done = -1;
cinfo->progress = &progress->pub;
}
@@ -73,8 +86,6 @@
}
}
-#endif
-
/*
* Case-insensitive matching of possibly-abbreviated keyword switches.