aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wright <jonathan.wright@arm.com>2021-08-09 10:09:36 +0100
committerJonathan Wright <jonathan.wright@arm.com>2021-08-10 11:03:56 +0100
commitff19e5b2e176c61d552f68768e0e051867745321 (patch)
treeabaf8670f4cdb272fb480e96d10fb6357d2f8ad9
parentad8b3b0f84baf155f3bde5626c3bf9d20535bcae (diff)
downloadlibjpeg-turbo-ff19e5b2e176c61d552f68768e0e051867745321.tar.gz
Update libjpeg-turbo to 2.1.1 stable release
Notable changes include a fix for a crash in the 64-bit SSE2 Huffman encoder. Bug: 1234259 Change-Id: Id764c5d8485f095a693504580d9ad81ba860d3ae
-rw-r--r--ChangeLog.md11
-rw-r--r--README.chromium6
-rw-r--r--jconfig.h4
-rw-r--r--jconfigint.h2
-rw-r--r--jcphuff.c5
-rw-r--r--jdhuff.c11
-rw-r--r--jmemmgr.c6
-rw-r--r--jpegint.h15
-rw-r--r--jpegtran.18
-rw-r--r--jpegtran.c7
-rw-r--r--simd/x86_64/jchuff-sse2.asm3
-rw-r--r--transupp.c8
-rw-r--r--transupp.h11
-rw-r--r--turbojpeg.c7
-rw-r--r--usage.txt3
15 files changed, 80 insertions, 27 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index ca5208be..1fcb065a 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -15,6 +15,17 @@ undefined C compiler behavior led to crashes ("SIGBUS: illegal alignment") on
Android systems when running AArch32/Thumb builds of libjpeg-turbo built with
recent versions of Clang.
+4. Added a command-line argument (`-copy icc`) to jpegtran that causes it to
+copy only the ICC profile markers from the source file and discard any other
+metadata.
+
+5. libjpeg-turbo should now build and run on CHERI-enabled architectures, which
+use capability pointers that are larger than the size of `size_t`.
+
+6. Fixed a regression introduced by 2.1 beta1[5] that caused a segfault in the
+64-bit SSE2 Huffman encoder when attempting to losslessly transform a
+specially-crafted malformed JPEG image.
+
2.1.0
=====
diff --git a/README.chromium b/README.chromium
index de1fe85e..5ccd34bb 100644
--- a/README.chromium
+++ b/README.chromium
@@ -1,6 +1,6 @@
Name: libjpeg-turbo
URL: https://github.com/libjpeg-turbo/libjpeg-turbo/
-Version: b201838d8b5f2f80c9f86ec8405a62a002232b2c (post 2.1.0)
+Version: 2.1.1
License: Custom license
License File: LICENSE.md
Security Critical: yes
@@ -8,14 +8,14 @@ License Android Compatible: yes
Description:
This consists of the components:
-* libjpeg-turbo b201838d8b5f2f80c9f86ec8405a62a002232b2c (post 2.1.0)
+* libjpeg-turbo 2.1.1
* This file (README.chromium)
* A build file (BUILD.gn)
* An OWNERS file
* A codereview.settings file
* Patched header files used by Chromium
* Deleted unused directories: cmakescripts, doc, fuzz, java, release,
- sharedlib, simd/loongson, simd/mips, simd/powerpc, and win
+ sharedlib, simd/mips, simd/mips64, simd/powerpc, and win
* Deleted unused files: appveyor.yml, CMakeLists.txt, doxygen.config,
doxygen-extra.css, .gitattributes, md5/CMakeLists.txt, md5/md5cmp.c,
simd/CMakeLists.txt, tjexample.c, tjexampletest.in, tjexampletest.java.in and
diff --git a/jconfig.h b/jconfig.h
index 0425e55d..ab74c456 100644
--- a/jconfig.h
+++ b/jconfig.h
@@ -4,10 +4,10 @@
#define JPEG_LIB_VERSION 62
/* libjpeg-turbo version */
-#define LIBJPEG_TURBO_VERSION 2.1.0
+#define LIBJPEG_TURBO_VERSION 2.1.1
/* libjpeg-turbo version in integer form */
-#define LIBJPEG_TURBO_VERSION_NUMBER 2001000
+#define LIBJPEG_TURBO_VERSION_NUMBER 2001001
/* Support arithmetic encoding */
/* #define C_ARITH_CODING_SUPPORTED 1 */
diff --git a/jconfigint.h b/jconfigint.h
index cb9915c9..16812049 100644
--- a/jconfigint.h
+++ b/jconfigint.h
@@ -26,7 +26,7 @@
#define PACKAGE_NAME "libjpeg-turbo"
/* Version number of package */
-#define VERSION "2.1.0"
+#define VERSION "2.1.1"
/* The size of `size_t', as computed by sizeof. */
#if __WORDSIZE==64 || defined(_WIN64)
diff --git a/jcphuff.c b/jcphuff.c
index 9bf96124..11019871 100644
--- a/jcphuff.c
+++ b/jcphuff.c
@@ -7,6 +7,7 @@
* Copyright (C) 2011, 2015, 2018, 2021, D. R. Commander.
* Copyright (C) 2016, 2018, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
+ * Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -680,7 +681,7 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
emit_restart(entropy, entropy->next_restart_num);
#ifdef WITH_SIMD
- cvalue = values = (JCOEF *)PAD((size_t)values_unaligned, 16);
+ cvalue = values = (JCOEF *)PAD((JUINTPTR)values_unaligned, 16);
#else
/* Not using SIMD, so alignment is not needed */
cvalue = values = values_unaligned;
@@ -945,7 +946,7 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
emit_restart(entropy, entropy->next_restart_num);
#ifdef WITH_SIMD
- cabsvalue = absvalues = (JCOEF *)PAD((size_t)absvalues_unaligned, 16);
+ cabsvalue = absvalues = (JCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
#else
/* Not using SIMD, so alignment is not needed */
cabsvalue = absvalues = absvalues_unaligned;
diff --git a/jdhuff.c b/jdhuff.c
index f786c105..679d2216 100644
--- a/jdhuff.c
+++ b/jdhuff.c
@@ -584,7 +584,7 @@ decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
* behavior is, to the best of our understanding, innocuous, and it is
* unclear how to work around it without potentially affecting
* performance. Thus, we (hopefully temporarily) suppress UBSan integer
- * overflow errors for this function.
+ * overflow errors for this function and decode_mcu_fast().
*/
s += state.last_dc_val[ci];
state.last_dc_val[ci] = s;
@@ -651,6 +651,12 @@ decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
}
+#if defined(__has_feature)
+#if __has_feature(undefined_behavior_sanitizer)
+__attribute__((no_sanitize("signed-integer-overflow"),
+ no_sanitize("unsigned-integer-overflow")))
+#endif
+#endif
LOCAL(boolean)
decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
@@ -681,6 +687,9 @@ decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
if (entropy->dc_needed[blkn]) {
int ci = cinfo->MCU_membership[blkn];
+ /* Refer to the comment in decode_mcu_slow() regarding the supression of
+ * a UBSan integer overflow error in this line of code.
+ */
s += state.last_dc_val[ci];
state.last_dc_val[ci] = s;
if (block)
diff --git a/jmemmgr.c b/jmemmgr.c
index 508ca742..70b8ec0c 100644
--- a/jmemmgr.c
+++ b/jmemmgr.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2016, D. R. Commander.
+ * Copyright (C) 2016, 2021, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -1032,7 +1032,7 @@ free_pool(j_common_ptr cinfo, int pool_id)
large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
space_freed = lhdr_ptr->bytes_used +
lhdr_ptr->bytes_left +
- sizeof(large_pool_hdr);
+ sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
mem->total_space_allocated -= space_freed;
lhdr_ptr = next_lhdr_ptr;
@@ -1045,7 +1045,7 @@ free_pool(j_common_ptr cinfo, int pool_id)
while (shdr_ptr != NULL) {
small_pool_ptr next_shdr_ptr = shdr_ptr->next;
space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
- sizeof(small_pool_hdr);
+ sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
mem->total_space_allocated -= space_freed;
shdr_ptr = next_shdr_ptr;
diff --git a/jpegint.h b/jpegint.h
index 195fbcb9..8c853479 100644
--- a/jpegint.h
+++ b/jpegint.h
@@ -5,8 +5,9 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015-2016, 2019, D. R. Commander.
+ * Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -47,6 +48,18 @@ typedef enum { /* Operating modes for buffer controllers */
/* JLONG must hold at least signed 32-bit values. */
typedef long JLONG;
+/* JUINTPTR must hold pointer values. */
+#ifdef __UINTPTR_TYPE__
+/*
+ * __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+.
+ * Fortunately, that is sufficient to support the few architectures for which
+ * sizeof(void *) != sizeof(size_t). The only other options would require C99
+ * or Clang-specific builtins.
+ */
+typedef __UINTPTR_TYPE__ JUINTPTR;
+#else
+typedef size_t JUINTPTR;
+#endif
/*
* Left shift macro that handles a negative operand without causing any
diff --git a/jpegtran.1 b/jpegtran.1
index da7a2669..5b1ded24 100644
--- a/jpegtran.1
+++ b/jpegtran.1
@@ -1,4 +1,4 @@
-.TH JPEGTRAN 1 "26 October 2020"
+.TH JPEGTRAN 1 "13 July 2021"
.SH NAME
jpegtran \- lossless transformation of JPEG files
.SH SYNOPSIS
@@ -247,6 +247,10 @@ comments and other metadata in the source file.
Copy only comment markers. This setting copies comments from the source file
but discards any other metadata.
.TP
+.B \-copy icc
+Copy only ICC profile markers. This setting copies the ICC profile from the
+source file but discards any other metadata.
+.TP
.B \-copy all
Copy all extra markers. This setting preserves miscellaneous markers
found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
@@ -261,7 +265,7 @@ Additional switches recognized by jpegtran are:
.BI \-icc " file"
Embed ICC color management profile contained in the specified file. Note that
this will cause \fBjpegtran\fR to ignore any APP2 markers in the input file,
-even if \fB-copy all\fR is specified.
+even if \fB-copy all\fR or \fB-copy icc\fR is specified.
.TP
.BI \-maxmemory " N"
Set limit for amount of memory to use in processing large images. Value is
diff --git a/jpegtran.c b/jpegtran.c
index 90fda7da..4af03497 100644
--- a/jpegtran.c
+++ b/jpegtran.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2014, 2017, 2019-2020, D. R. Commander.
+ * Copyright (C) 2010, 2014, 2017, 2019-2021, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -64,6 +64,7 @@ usage(void)
fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -copy none Copy no extra markers from source file\n");
fprintf(stderr, " -copy comments Copy only comment markers (default)\n");
+ fprintf(stderr, " -copy icc Copy only ICC profile markers\n");
fprintf(stderr, " -copy all Copy all extra markers\n");
#ifdef ENTROPY_OPT_SUPPORTED
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
@@ -196,6 +197,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
copyoption = JCOPYOPT_NONE;
} else if (keymatch(argv[argn], "comments", 1)) {
copyoption = JCOPYOPT_COMMENTS;
+ } else if (keymatch(argv[argn], "icc", 1)) {
+ copyoption = JCOPYOPT_ICC;
} else if (keymatch(argv[argn], "all", 1)) {
copyoption = JCOPYOPT_ALL;
} else
@@ -574,6 +577,8 @@ main(int argc, char **argv)
fclose(icc_file);
if (copyoption == JCOPYOPT_ALL)
copyoption = JCOPYOPT_ALL_EXCEPT_ICC;
+ if (copyoption == JCOPYOPT_ICC)
+ copyoption = JCOPYOPT_NONE;
}
if (report) {
diff --git a/simd/x86_64/jchuff-sse2.asm b/simd/x86_64/jchuff-sse2.asm
index 00720283..9ea6df94 100644
--- a/simd/x86_64/jchuff-sse2.asm
+++ b/simd/x86_64/jchuff-sse2.asm
@@ -1,7 +1,7 @@
;
; jchuff-sse2.asm - Huffman entropy encoding (64-bit SSE2)
;
-; Copyright (C) 2009-2011, 2014-2016, 2019, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
;
@@ -83,6 +83,7 @@ times 1 << 11 db 12
times 1 << 12 db 13
times 1 << 13 db 14
times 1 << 14 db 15
+times 1 << 15 db 16
alignz 32
diff --git a/transupp.c b/transupp.c
index 6e860778..ce30ab7b 100644
--- a/transupp.c
+++ b/transupp.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2017, D. R. Commander.
+ * Copyright (C) 2010, 2017, 2021, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -2310,7 +2310,7 @@ jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
int m;
/* Save comments except under NONE option */
- if (option != JCOPYOPT_NONE) {
+ if (option != JCOPYOPT_NONE && option != JCOPYOPT_ICC) {
jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF);
}
/* Save all types of APPn markers iff ALL option */
@@ -2321,6 +2321,10 @@ jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF);
}
}
+ /* Save only APP2 markers if ICC option selected */
+ if (option == JCOPYOPT_ICC) {
+ jpeg_save_markers(srcinfo, JPEG_APP0 + 2, 0xFFFF);
+ }
#endif /* SAVE_MARKERS_SUPPORTED */
}
diff --git a/transupp.h b/transupp.h
index ea6be1fc..cea1f409 100644
--- a/transupp.h
+++ b/transupp.h
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, D. R. Commander.
+ * Copyright (C) 2017, 2021, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -213,10 +213,11 @@ EXTERN(boolean) jtransform_perfect_transform(JDIMENSION image_width,
*/
typedef enum {
- JCOPYOPT_NONE, /* copy no optional markers */
- JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
- JCOPYOPT_ALL, /* copy all optional markers */
- JCOPYOPT_ALL_EXCEPT_ICC /* copy all optional markers except APP2 */
+ JCOPYOPT_NONE, /* copy no optional markers */
+ JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
+ JCOPYOPT_ALL, /* copy all optional markers */
+ JCOPYOPT_ALL_EXCEPT_ICC, /* copy all optional markers except APP2 */
+ JCOPYOPT_ICC /* copy only ICC profile (APP2) markers */
} JCOPY_OPTION;
#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
diff --git a/turbojpeg.c b/turbojpeg.c
index 793a3eed..47c59993 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1,5 +1,6 @@
/*
* Copyright (C)2009-2021 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021 Alex Richardson. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -845,7 +846,7 @@ DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
THROW("tjEncodeYUVPlanes(): Memory allocation failure");
for (row = 0; row < cinfo->max_v_samp_factor; row++) {
unsigned char *_tmpbuf_aligned =
- (unsigned char *)PAD((size_t)_tmpbuf[i], 32);
+ (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
tmpbuf[i][row] = &_tmpbuf_aligned[
PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
@@ -861,7 +862,7 @@ DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
THROW("tjEncodeYUVPlanes(): Memory allocation failure");
for (row = 0; row < compptr->v_samp_factor; row++) {
unsigned char *_tmpbuf2_aligned =
- (unsigned char *)PAD((size_t)_tmpbuf2[i], 32);
+ (unsigned char *)PAD((JUINTPTR)_tmpbuf2[i], 32);
tmpbuf2[i][row] =
&_tmpbuf2_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
@@ -1524,7 +1525,7 @@ DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
THROW("tjDecodeYUVPlanes(): Memory allocation failure");
for (row = 0; row < compptr->v_samp_factor; row++) {
unsigned char *_tmpbuf_aligned =
- (unsigned char *)PAD((size_t)_tmpbuf[i], 32);
+ (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
tmpbuf[i][row] =
&_tmpbuf_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
diff --git a/usage.txt b/usage.txt
index f7fa3c08..b60a593f 100644
--- a/usage.txt
+++ b/usage.txt
@@ -601,6 +601,9 @@ markers, such as comment blocks:
-copy comments Copy only comment markers. This setting copies
comments from the source file but discards any other
metadata.
+ -copy icc Copy only ICC profile markers. This setting copies the
+ ICC profile from the source file but discards any other
+ metadata.
-copy all Copy all extra markers. This setting preserves
miscellaneous markers found in the source file, such
as JFIF thumbnails, Exif data, and Photoshop settings.