]> granicus.if.org Git - libjpeg-turbo/commit
TurboJPEG: Properly handle gigapixel images
authorDRC <information@libjpeg-turbo.org>
Thu, 11 Jul 2019 20:30:04 +0000 (15:30 -0500)
committerDRC <information@libjpeg-turbo.org>
Thu, 11 Jul 2019 21:56:50 +0000 (16:56 -0500)
commit2a9e3bd7430cfda1bc812d139e0609c6aca0b884
tree876351e66b4232828d946e0e85a32949305bde8e
parentf37b7c1f96154f943eb358914081bfbad197bb71
TurboJPEG: Properly handle gigapixel images

Prevent several integer overflow issues and subsequent segfaults that
occurred when attempting to compress or decompress gigapixel images with
the TurboJPEG API:

- Modify tjBufSize(), tjBufSizeYUV2(), and tjPlaneSizeYUV() to avoid
  integer overflow when computing the return values and to return an
  error if such an overflow is unavoidable.
- Modify tjunittest to validate the above.
- Modify tjCompress2(), tjEncodeYUVPlanes(), tjDecompress2(), and
  tjDecodeYUVPlanes() to avoid integer overflow when computing the row
  pointers in the 64-bit TurboJPEG C API.
- Modify TJBench (both C and Java versions) to avoid overflowing the
  size argument to malloc()/new and to fail gracefully if such an
  overflow is unavoidable.

In general, this allows gigapixel images to be accommodated by the
64-bit TurboJPEG C API when using automatic JPEG buffer (re)allocation.
Such images cannot currently be accommodated without automatic JPEG
buffer (re)allocation, due to the fact that tjAlloc() accepts a 32-bit
integer argument (oops.)  Such images cannot be accommodated in the
TurboJPEG Java API due to the fact that Java always uses a signed 32-bit
integer as an array index.

Fixes #361
ChangeLog.md
java/TJBench.java
tjbench.c
tjunittest.c
turbojpeg.c