Skip to content

Commit af265e7

Browse files
committed
Merge tag '2.1.5'
* tag '2.1.5': (41 commits) BUILDING.md: Specify install prefix for MinGW/Un*x Java: Guard against int overflow in size methods turbojpeg.c: Fix UBSan warning tjPlane*(): Guard against int overflow Java doc: TJ.pixelSize --> TJ.getPixelSize() TJBench: Unset TJ*OPT_CROP when disabling tiling TJExample: Remove "underlying codec" references GitHub: Update to actions/checkout@v3 TJBench: Set TJ*OPT_PROGRESSIVE with -progressive TJBench/Java: Fix parsing of quality ranges TJBench: Strictly check all non-boolean arguments TurboJPEG: More documentation improvements TJDecompressor.java: Exception message tweak 12-bit: Set alpha channel to 4095 rather than 255 TJDecompressor.java: "YUV" = "planar YUV" Java: Don't allow int overflow in buf size methods tjDecompressToYUV2: Use scaled dims for plane calc TurboJPEG: Numerous documentation improvements TurboJPEG: Don't use backward compatibility macros TurboJPEG: Ensure 'pad' arg is a power of 2 ...
2 parents fd56921 + 3b19db4 commit af265e7

70 files changed

Lines changed: 2482 additions & 2157 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BUILDING.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Build Requirements
2525
variable or the `ASM_NASM` environment variable. On Windows, use forward
2626
slashes rather than backslashes in the path (for example,
2727
**c:/nasm/nasm.exe**).
28-
* NASM and Yasm are located in the CRB (Code Ready Builder) repository on
29-
Red Hat Enterprise Linux 8 and in the PowerTools repository on RHEL
30-
derivatives, which is not enabled by default.
28+
* NASM and Yasm are located in the CRB (Code Ready Builder) or PowerTools
29+
repository on Red Hat Enterprise Linux 8+ and derivatives, which is not
30+
enabled by default.
3131

3232
### Un*x Platforms (including Linux, Mac, FreeBSD, Solaris, and Cygwin)
3333

@@ -390,9 +390,13 @@ located (usually **/usr/bin**.) Next, execute the following commands:
390390

391391
cd {build_directory}
392392
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
393+
-DCMAKE_INSTALL_PREFIX={install_path} \
393394
[additional CMake flags] {source_directory}
394395
make
395396

397+
*{install\_path}* is the path under which the libjpeg-turbo binaries should be
398+
installed.
399+
396400

397401
### 64-bit MinGW Build on Un*x (including Mac and Cygwin)
398402

@@ -409,9 +413,13 @@ located (usually **/usr/bin**.) Next, execute the following commands:
409413

410414
cd {build_directory}
411415
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
416+
-DCMAKE_INSTALL_PREFIX={install_path} \
412417
[additional CMake flags] {source_directory}
413418
make
414419

420+
*{install\_path}* is the path under which the libjpeg-turbo binaries should be
421+
installed.
422+
415423

416424
Building libjpeg-turbo for iOS
417425
------------------------------
@@ -447,6 +455,10 @@ iPhone 5S/iPad Mini 2/iPad Air and newer.
447455
[additional CMake flags] {source_directory}
448456
make
449457

458+
Replace `iPhoneOS` with `iPhoneSimulator` and `-miphoneos-version-min` with
459+
`-miphonesimulator-version-min` to build libjpeg-turbo for the iOS simulator on
460+
Macs with Apple silicon CPUs.
461+
450462

451463
Building libjpeg-turbo for Android
452464
----------------------------------

CMakeLists.txt

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ if(CMAKE_EXECUTABLE_SUFFIX)
1010
endif()
1111

1212
project(mozjpeg C)
13-
set(VERSION 4.1.2)
14-
set(COPYRIGHT_YEAR "1991-2022")
13+
set(VERSION 4.1.3)
14+
set(COPYRIGHT_YEAR "1991-2023")
1515
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
1616
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
1717
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
@@ -40,6 +40,15 @@ set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVIS
4040
# application bundles would break our iOS packages.)
4141
set(CMAKE_MACOSX_BUNDLE FALSE)
4242

43+
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY
44+
GENERATOR_IS_MULTI_CONFIG)
45+
# If the GENERATOR_IS_MULTI_CONFIG property doesn't exist (CMake < 3.9), then
46+
# set the GENERATOR_IS_MULTI_CONFIG variable manually if the generator is
47+
# Visual Studio or Xcode (the only multi-config generators in CMake < 3.9).
48+
if(NOT GENERATOR_IS_MULTI_CONFIG AND (MSVC_IDE OR XCODE))
49+
set(GENERATOR_IS_MULTI_CONFIG TRUE)
50+
endif()
51+
4352
string(TIMESTAMP DEFAULT_BUILD "%Y%m%d")
4453
set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})")
4554

@@ -289,6 +298,16 @@ if(NOT WITH_JPEG8)
289298
report_option(WITH_MEM_SRCDST "In-memory source/destination managers")
290299
endif()
291300

301+
# 0: Original libjpeg v6b/v7/v8 API/ABI
302+
#
303+
# libjpeg v6b/v7 API/ABI emulation:
304+
# 1: + In-memory source/destination managers (libjpeg-turbo 1.3.x)
305+
# 2: + Partial image decompression functions (libjpeg-turbo 1.5.x)
306+
# 3: + ICC functions (libjpeg-turbo 2.0.x)
307+
#
308+
# libjpeg v8 API/ABI emulation:
309+
# 1: + Partial image decompression functions (libjpeg-turbo 1.5.x)
310+
# 2: + ICC functions (libjpeg-turbo 2.0.x)
292311
set(SO_AGE 2)
293312
if(WITH_MEM_SRCDST)
294313
set(SO_AGE 3)
@@ -339,8 +358,19 @@ message(STATUS "libjpeg API shared library version = ${SO_MAJOR_VERSION}.${SO_AG
339358
# names of functions whenever they are modified in a backward-incompatible
340359
# manner, it is always backward-ABI-compatible with itself, so the major and
341360
# minor SO versions don't change. However, we increase the middle number (the
342-
# SO "age") whenever functions are added to the API.
361+
# SO "age") whenever functions are added to the API, because adding functions
362+
# affects forward API/ABI compatibility.
343363
set(TURBOJPEG_SO_MAJOR_VERSION 0)
364+
# 0: TurboJPEG 1.3.x API
365+
# 1: TurboJPEG 1.4.x API
366+
# The TurboJPEG 1.5.x API modified some of the function prototypes, adding
367+
# the const keyword in front of pointers to unmodified buffers, but that did
368+
# not affect forward API/ABI compatibility.
369+
# 2: TurboJPEG 2.0.x API
370+
# The TurboJPEG 2.1.x API modified the behavior of the tjDecompressHeader3()
371+
# function so that it accepts "abbreviated table specification" (AKA
372+
# "tables-only") datastreams as well as JPEG images, but that did not affect
373+
# forward API/ABI compatibility.
344374
set(TURBOJPEG_SO_AGE 2)
345375
set(TURBOJPEG_SO_VERSION 0.${TURBOJPEG_SO_AGE}.0)
346376

@@ -761,7 +791,7 @@ add_executable(strtest strtest.c)
761791

762792
add_subdirectory(md5)
763793

764-
if(MSVC_IDE OR XCODE)
794+
if(GENERATOR_IS_MULTI_CONFIG)
765795
set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
766796
else()
767797
set(OBJDIR "")
@@ -1400,14 +1430,15 @@ if(WITH_TURBOJPEG)
14001430
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -yuv
14011431
COMMAND echo tjbenchtest.java -progressive
14021432
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -progressive
1403-
COMMAND echo tjexampletest.java -progressive -yuv
1433+
COMMAND echo tjbenchtest.java -progressive -yuv
14041434
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
14051435
-progressive -yuv
14061436
COMMAND echo tjexampletest.java
14071437
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java
14081438
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
14091439
${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
1410-
${CMAKE_CURRENT_BINARY_DIR}/tjexampletest)
1440+
${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
1441+
${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java)
14111442
else()
14121443
add_custom_target(tjtest
14131444
COMMAND echo tjbenchtest
@@ -1424,7 +1455,8 @@ if(WITH_TURBOJPEG)
14241455
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
14251456
COMMAND echo tjexampletest
14261457
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
1427-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
1458+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
1459+
${CMAKE_CURRENT_BINARY_DIR}/tjexampletest)
14281460
endif()
14291461
endif()
14301462

@@ -1455,7 +1487,7 @@ if(WITH_TURBOJPEG)
14551487
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
14561488
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
14571489
if(NOT ENABLE_SHARED)
1458-
if(MSVC_IDE OR XCODE)
1490+
if(GENERATOR_IS_MULTI_CONFIG)
14591491
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
14601492
else()
14611493
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
@@ -1473,7 +1505,7 @@ if(ENABLE_STATIC)
14731505
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
14741506
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
14751507
if(NOT ENABLE_SHARED)
1476-
if(MSVC_IDE OR XCODE)
1508+
if(GENERATOR_IS_MULTI_CONFIG)
14771509
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
14781510
else()
14791511
set(DIR ${CMAKE_CURRENT_BINARY_DIR})

ChangeLog.md

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,62 @@
1+
2.1.5
2+
=====
3+
4+
### Significant changes relative to 2.1.4:
5+
6+
1. Fixed issues in the build system whereby, when using the Ninja Multi-Config
7+
CMake generator, a static build of libjpeg-turbo (a build in which
8+
`ENABLE_SHARED` is `0`) could not be installed, a Windows installer could not
9+
be built, and the Java regression tests failed.
10+
11+
2. Fixed a regression introduced by 2.0 beta1[15] that caused a buffer overrun
12+
in the progressive Huffman encoder when attempting to transform a
13+
specially-crafted malformed 12-bit-per-component JPEG image into a progressive
14+
12-bit-per-component JPEG image using a 12-bit-per-component build of
15+
libjpeg-turbo (`-DWITH_12BIT=1`.) Given that the buffer overrun was fully
16+
contained within the progressive Huffman encoder structure and did not cause a
17+
segfault or other user-visible errant behavior, given that the lossless
18+
transformer (unlike the decompressor) is not generally exposed to arbitrary
19+
data exploits, and given that 12-bit-per-component builds of libjpeg-turbo are
20+
uncommon, this issue did not likely pose a security risk.
21+
22+
3. Fixed an issue whereby, when using a 12-bit-per-component build of
23+
libjpeg-turbo (`-DWITH_12BIT=1`), passing samples with values greater than 4095
24+
or less than 0 to `jpeg_write_scanlines()` caused a buffer overrun or underrun
25+
in the RGB-to-YCbCr color converter.
26+
27+
4. Fixed a floating point exception that occurred when attempting to use the
28+
jpegtran `-drop` and `-trim` options to losslessly transform a
29+
specially-crafted malformed JPEG image.
30+
31+
5. Fixed an issue in `tjBufSizeYUV2()` whereby it returned a bogus result,
32+
rather than throwing an error, if the `align` parameter was not a power of 2.
33+
Fixed a similar issue in `tjCompressFromYUV()` whereby it generated a corrupt
34+
JPEG image in certain cases, rather than throwing an error, if the `align`
35+
parameter was not a power of 2.
36+
37+
6. Fixed an issue whereby `tjDecompressToYUV2()`, which is a wrapper for
38+
`tjDecompressToYUVPlanes()`, used the desired YUV image dimensions rather than
39+
the actual scaled image dimensions when computing the plane pointers and
40+
strides to pass to `tjDecompressToYUVPlanes()`. This caused a buffer overrun
41+
and subsequent segfault if the desired image dimensions exceeded the scaled
42+
image dimensions.
43+
44+
7. Fixed an issue whereby, when decompressing a 12-bit-per-component JPEG image
45+
(`-DWITH_12BIT=1`) using an alpha-enabled output color space such as
46+
`JCS_EXT_RGBA`, the alpha channel was set to 255 rather than 4095.
47+
48+
8. Fixed an issue whereby the Java version of TJBench did not accept a range of
49+
quality values.
50+
51+
9. Fixed an issue whereby, when `-progressive` was passed to TJBench, the JPEG
52+
input image was not transformed into a progressive JPEG image prior to
53+
decompression.
54+
55+
156
2.1.4
257
=====
358

4-
### Significant changes relative to 2.1.3
59+
### Significant changes relative to 2.1.3:
560

661
1. Fixed a regression introduced in 2.1.3 that caused build failures with
762
Visual Studio 2010.
@@ -36,7 +91,7 @@ virtual array access") under certain circumstances.
3691
2.1.3
3792
=====
3893

39-
### Significant changes relative to 2.1.2
94+
### Significant changes relative to 2.1.2:
4095

4196
1. Fixed a regression introduced by 2.0 beta1[7] whereby cjpeg compressed PGM
4297
input files into full-color JPEG images unless the `-grayscale` option was
@@ -60,7 +115,7 @@ be reproduced using the libjpeg API, not using djpeg.
60115
2.1.2
61116
=====
62117

63-
### Significant changes relative to 2.1.1
118+
### Significant changes relative to 2.1.1:
64119

65120
1. Fixed a regression introduced by 2.1 beta1[13] that caused the remaining
66121
GAS implementations of AArch64 (Arm 64-bit) Neon SIMD functions (which are used
@@ -92,7 +147,7 @@ image contains incomplete or corrupt image data.
92147
2.1.1
93148
=====
94149

95-
### Significant changes relative to 2.1.0
150+
### Significant changes relative to 2.1.0:
96151

97152
1. Fixed a regression introduced in 2.1.0 that caused build failures with
98153
non-GCC-compatible compilers for Un*x/Arm platforms.
@@ -121,7 +176,7 @@ transform a specially-crafted malformed JPEG image.
121176
2.1.0
122177
=====
123178

124-
### Significant changes relative to 2.1 beta1
179+
### Significant changes relative to 2.1 beta1:
125180

126181
1. Fixed a regression introduced by 2.1 beta1[6(b)] whereby attempting to
127182
decompress certain progressive JPEG images with one or more component planes of
@@ -156,10 +211,10 @@ progressive JPEG format described in the report
156211
["Two Issues with the JPEG Standard"](https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
157212

158213
7. The PPM reader now throws an error, rather than segfaulting (due to a buffer
159-
overrun) or generating incorrect pixels, if an application attempts to use the
160-
`tjLoadImage()` function to load a 16-bit binary PPM file (a binary PPM file
161-
with a maximum value greater than 255) into a grayscale image buffer or to load
162-
a 16-bit binary PGM file into an RGB image buffer.
214+
overrun, CVE-2021-46822) or generating incorrect pixels, if an application
215+
attempts to use the `tjLoadImage()` function to load a 16-bit binary PPM file
216+
(a binary PPM file with a maximum value greater than 255) into a grayscale
217+
image buffer or to load a 16-bit binary PGM file into an RGB image buffer.
163218

164219
8. Fixed an issue in the PPM reader that caused incorrect pixels to be
165220
generated when using the `tjLoadImage()` function to load a 16-bit binary PPM
@@ -325,11 +380,11 @@ methods in the TurboJPEG Java API.
325380

326381
2. Fixed or worked around multiple issues with `jpeg_skip_scanlines()`:
327382

328-
- Fixed segfaults or "Corrupt JPEG data: premature end of data segment"
329-
errors in `jpeg_skip_scanlines()` that occurred when decompressing 4:2:2 or
330-
4:2:0 JPEG images using merged (non-fancy) upsampling/color conversion (that
331-
is, when setting `cinfo.do_fancy_upsampling` to `FALSE`.) 2.0.0[6] was a
332-
similar fix, but it did not cover all cases.
383+
- Fixed segfaults (CVE-2020-35538) or "Corrupt JPEG data: premature end of
384+
data segment" errors in `jpeg_skip_scanlines()` that occurred when
385+
decompressing 4:2:2 or 4:2:0 JPEG images using merged (non-fancy)
386+
upsampling/color conversion (that is, when setting `cinfo.do_fancy_upsampling`
387+
to `FALSE`.) 2.0.0[6] was a similar fix, but it did not cover all cases.
333388
- `jpeg_skip_scanlines()` now throws an error if two-pass color
334389
quantization is enabled. Two-pass color quantization never worked properly
335390
with `jpeg_skip_scanlines()`, and the issues could not readily be fixed.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ best of our understanding.
9191
The Modified (3-clause) BSD License
9292
===================================
9393

94-
Copyright (C)2009-2022 D. R. Commander. All Rights Reserved.<br>
94+
Copyright (C)2009-2023 D. R. Commander. All Rights Reserved.<br>
9595
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
9696

9797
Redistribution and use in source and binary forms, with or without

cmakescripts/BuildPackages.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if(WITH_JAVA)
9090
set(INST_DEFS ${INST_DEFS} -DJAVA)
9191
endif()
9292

93-
if(MSVC_IDE)
93+
if(GENERATOR_IS_MULTI_CONFIG)
9494
set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
9595
else()
9696
set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")

cmyk.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <jinclude.h>
1818
#define JPEG_INTERNALS
1919
#include <jpeglib.h>
20-
#include "jconfigint.h"
2120

2221

2322
/* Fully reversible */

djpeg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
316316
if (++argn >= argc) /* advance to next argument */
317317
usage();
318318
icc_filename = argv[argn];
319+
#ifdef SAVE_MARKERS_SUPPORTED
319320
jpeg_save_markers(cinfo, JPEG_APP0 + 2, 0xFFFF);
321+
#endif
320322

321323
} else if (keymatch(arg, "map", 3)) {
322324
/* Quantize to a color map taken from an input file. */

0 commit comments

Comments
 (0)