This commit is contained in:
parent
f298c7e204
commit
a330170971
34
libtiff-CVE-2022-0865.patch
Normal file
34
libtiff-CVE-2022-0865.patch
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
From 26be9b079af5eda5c4b90ee6632adf25750cb38a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Even Rouault <even.rouault@spatialys.com>
|
||||||
|
Date: Thu, 24 Feb 2022 22:26:02 +0100
|
||||||
|
Subject: [PATCH 2/3] tif_jbig.c: fix crash when reading a file with multiple
|
||||||
|
IFD in memory-mapped mode and when bit reversal is needed (fixes #385)
|
||||||
|
|
||||||
|
---
|
||||||
|
libtiff/tif_jbig.c | 10 ++++++++++
|
||||||
|
1 file changed, 10 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c
|
||||||
|
index 7408633..8bfa4ce 100644
|
||||||
|
--- a/libtiff/tif_jbig.c
|
||||||
|
+++ b/libtiff/tif_jbig.c
|
||||||
|
@@ -209,6 +209,16 @@ int TIFFInitJBIG(TIFF* tif, int scheme)
|
||||||
|
*/
|
||||||
|
tif->tif_flags |= TIFF_NOBITREV;
|
||||||
|
tif->tif_flags &= ~TIFF_MAPPED;
|
||||||
|
+ /* We may have read from a previous IFD and thus set TIFF_BUFFERMMAP and
|
||||||
|
+ * cleared TIFF_MYBUFFER. It is necessary to restore them to their initial
|
||||||
|
+ * value to be consistent with the state of a non-memory mapped file.
|
||||||
|
+ */
|
||||||
|
+ if (tif->tif_flags&TIFF_BUFFERMMAP) {
|
||||||
|
+ tif->tif_rawdata = NULL;
|
||||||
|
+ tif->tif_rawdatasize = 0;
|
||||||
|
+ tif->tif_flags &= ~TIFF_BUFFERMMAP;
|
||||||
|
+ tif->tif_flags |= TIFF_MYBUFFER;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/* Setup the function pointers for encode, decode, and cleanup. */
|
||||||
|
tif->tif_setupdecode = JBIGSetupDecode;
|
||||||
|
--
|
||||||
|
2.35.1
|
||||||
|
|
214
libtiff-CVE-2022-0891.patch
Normal file
214
libtiff-CVE-2022-0891.patch
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
From 8a4097911df4e1a3d577ccdfa13a35984b0e5b2b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Su Laus <sulau@freenet.de>
|
||||||
|
Date: Tue, 8 Mar 2022 17:02:44 +0000
|
||||||
|
Subject: [PATCH 1/3] tiffcrop: fix issue #380 and #382 heap buffer overflow in
|
||||||
|
extractImageSection
|
||||||
|
|
||||||
|
---
|
||||||
|
tools/tiffcrop.c | 92 +++++++++++++++++++-----------------------------
|
||||||
|
1 file changed, 36 insertions(+), 56 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
|
||||||
|
index b85c2ce..302a7e9 100644
|
||||||
|
--- a/tools/tiffcrop.c
|
||||||
|
+++ b/tools/tiffcrop.c
|
||||||
|
@@ -105,8 +105,8 @@
|
||||||
|
* of messages to monitor progress without enabling dump logs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-static char tiffcrop_version_id[] = "2.4";
|
||||||
|
-static char tiffcrop_rev_date[] = "12-13-2010";
|
||||||
|
+static char tiffcrop_version_id[] = "2.4.1";
|
||||||
|
+static char tiffcrop_rev_date[] = "03-03-2010";
|
||||||
|
|
||||||
|
#include "tif_config.h"
|
||||||
|
#include "libport.h"
|
||||||
|
@@ -6710,10 +6710,10 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
uint32_t img_length;
|
||||||
|
#endif
|
||||||
|
- uint32_t j, shift1, shift2, trailing_bits;
|
||||||
|
+ uint32_t j, shift1, trailing_bits;
|
||||||
|
uint32_t row, first_row, last_row, first_col, last_col;
|
||||||
|
uint32_t src_offset, dst_offset, row_offset, col_offset;
|
||||||
|
- uint32_t offset1, offset2, full_bytes;
|
||||||
|
+ uint32_t offset1, full_bytes;
|
||||||
|
uint32_t sect_width;
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
uint32_t sect_length;
|
||||||
|
@@ -6723,7 +6723,6 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
int k;
|
||||||
|
unsigned char bitset;
|
||||||
|
- static char *bitarray = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
img_width = image->width;
|
||||||
|
@@ -6741,17 +6740,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
dst_offset = 0;
|
||||||
|
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
- if (bitarray == NULL)
|
||||||
|
- {
|
||||||
|
- if ((bitarray = (char *)malloc(img_width)) == NULL)
|
||||||
|
- {
|
||||||
|
- TIFFError ("", "DEBUG: Unable to allocate debugging bitarray");
|
||||||
|
- return (-1);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ char bitarray[39];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
- /* rows, columns, width, length are expressed in pixels */
|
||||||
|
+ /* rows, columns, width, length are expressed in pixels
|
||||||
|
+ * first_row, last_row, .. are index into image array starting at 0 to width-1,
|
||||||
|
+ * last_col shall be also extracted. */
|
||||||
|
first_row = section->y1;
|
||||||
|
last_row = section->y2;
|
||||||
|
first_col = section->x1;
|
||||||
|
@@ -6761,9 +6755,14 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
sect_length = last_row - first_row + 1;
|
||||||
|
#endif
|
||||||
|
- img_rowsize = ((img_width * bps + 7) / 8) * spp;
|
||||||
|
- full_bytes = (sect_width * spp * bps) / 8; /* number of COMPLETE bytes per row in section */
|
||||||
|
- trailing_bits = (sect_width * bps) % 8;
|
||||||
|
+ /* The read function loadImage() used copy separate plane data into a buffer as interleaved
|
||||||
|
+ * samples rather than separate planes so the same logic works to extract regions
|
||||||
|
+ * regardless of the way the data are organized in the input file.
|
||||||
|
+ * Furthermore, bytes and bits are arranged in buffer according to COMPRESSION=1 and FILLORDER=1
|
||||||
|
+ */
|
||||||
|
+ img_rowsize = (((img_width * spp * bps) + 7) / 8); /* row size in full bytes of source image */
|
||||||
|
+ full_bytes = (sect_width * spp * bps) / 8; /* number of COMPLETE bytes per row in section */
|
||||||
|
+ trailing_bits = (sect_width * spp * bps) % 8; /* trailing bits within the last byte of destination buffer */
|
||||||
|
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
TIFFError ("", "First row: %"PRIu32", last row: %"PRIu32", First col: %"PRIu32", last col: %"PRIu32"\n",
|
||||||
|
@@ -6776,10 +6775,9 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
|
||||||
|
if ((bps % 8) == 0)
|
||||||
|
{
|
||||||
|
- col_offset = first_col * spp * bps / 8;
|
||||||
|
+ col_offset = (first_col * spp * bps) / 8;
|
||||||
|
for (row = first_row; row <= last_row; row++)
|
||||||
|
{
|
||||||
|
- /* row_offset = row * img_width * spp * bps / 8; */
|
||||||
|
row_offset = row * img_rowsize;
|
||||||
|
src_offset = row_offset + col_offset;
|
||||||
|
|
||||||
|
@@ -6792,14 +6790,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* bps != 8 */
|
||||||
|
- shift1 = spp * ((first_col * bps) % 8);
|
||||||
|
- shift2 = spp * ((last_col * bps) % 8);
|
||||||
|
+ shift1 = ((first_col * spp * bps) % 8); /* shift1 = bits to skip in the first byte of source buffer*/
|
||||||
|
for (row = first_row; row <= last_row; row++)
|
||||||
|
{
|
||||||
|
/* pull out the first byte */
|
||||||
|
row_offset = row * img_rowsize;
|
||||||
|
- offset1 = row_offset + (first_col * bps / 8);
|
||||||
|
- offset2 = row_offset + (last_col * bps / 8);
|
||||||
|
+ offset1 = row_offset + ((first_col * spp * bps) / 8); /* offset1 = offset into source of byte with first bits to be extracted */
|
||||||
|
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
for (j = 0, k = 7; j < 8; j++, k--)
|
||||||
|
@@ -6811,12 +6807,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
sprintf(&bitarray[9], " ");
|
||||||
|
for (j = 10, k = 7; j < 18; j++, k--)
|
||||||
|
{
|
||||||
|
- bitset = *(src_buff + offset2) & (((unsigned char)1 << k)) ? 1 : 0;
|
||||||
|
+ bitset = *(src_buff + offset1 + full_bytes) & (((unsigned char)1 << k)) ? 1 : 0;
|
||||||
|
sprintf(&bitarray[j], (bitset) ? "1" : "0");
|
||||||
|
}
|
||||||
|
bitarray[18] = '\0';
|
||||||
|
- TIFFError ("", "Row: %3d Offset1: %"PRIu32", Shift1: %"PRIu32", Offset2: %"PRIu32", Shift2: %"PRIu32"\n",
|
||||||
|
- row, offset1, shift1, offset2, shift2);
|
||||||
|
+ TIFFError ("", "Row: %3d Offset1: %"PRIu32", Shift1: %"PRIu32", Offset2: %"PRIu32", Trailing_bits: %"PRIu32"\n",
|
||||||
|
+ row, offset1, shift1, offset1+full_bytes, trailing_bits);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bytebuff1 = bytebuff2 = 0;
|
||||||
|
@@ -6840,11 +6836,12 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
|
||||||
|
if (trailing_bits != 0)
|
||||||
|
{
|
||||||
|
- bytebuff2 = src_buff[offset2] & ((unsigned char)255 << (7 - shift2));
|
||||||
|
+ /* Only copy higher bits of samples and mask lower bits of not wanted column samples to zero */
|
||||||
|
+ bytebuff2 = src_buff[offset1 + full_bytes] & ((unsigned char)255 << (8 - trailing_bits));
|
||||||
|
sect_buff[dst_offset] = bytebuff2;
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
TIFFError ("", " Trailing bits src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n",
|
||||||
|
- offset2, dst_offset);
|
||||||
|
+ offset1 + full_bytes, dst_offset);
|
||||||
|
for (j = 30, k = 7; j < 38; j++, k--)
|
||||||
|
{
|
||||||
|
bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0;
|
||||||
|
@@ -6863,8 +6860,10 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
#endif
|
||||||
|
for (j = 0; j <= full_bytes; j++)
|
||||||
|
{
|
||||||
|
- bytebuff1 = src_buff[offset1 + j] & ((unsigned char)255 >> shift1);
|
||||||
|
- bytebuff2 = src_buff[offset1 + j + 1] & ((unsigned char)255 << (7 - shift1));
|
||||||
|
+ /* Skip the first shift1 bits and shift the source up by shift1 bits before save to destination.*/
|
||||||
|
+ /* Attention: src_buff size needs to be some bytes larger than image size, because could read behind image here. */
|
||||||
|
+ bytebuff1 = src_buff[offset1 + j] & ((unsigned char)255 >> shift1);
|
||||||
|
+ bytebuff2 = src_buff[offset1 + j + 1] & ((unsigned char)255 << (8 - shift1));
|
||||||
|
sect_buff[dst_offset + j] = (bytebuff1 << shift1) | (bytebuff2 >> (8 - shift1));
|
||||||
|
}
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
@@ -6880,36 +6879,17 @@ extractImageSection(struct image_data *image, struct pageseg *section,
|
||||||
|
#endif
|
||||||
|
dst_offset += full_bytes;
|
||||||
|
|
||||||
|
+ /* Copy the trailing_bits for the last byte in the destination buffer.
|
||||||
|
+ Could come from one ore two bytes of the source buffer. */
|
||||||
|
if (trailing_bits != 0)
|
||||||
|
{
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
- TIFFError ("", " Trailing bits src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1 + full_bytes, dst_offset);
|
||||||
|
-#endif
|
||||||
|
- if (shift2 > shift1)
|
||||||
|
- {
|
||||||
|
- bytebuff1 = src_buff[offset1 + full_bytes] & ((unsigned char)255 << (7 - shift2));
|
||||||
|
- bytebuff2 = bytebuff1 & ((unsigned char)255 << shift1);
|
||||||
|
- sect_buff[dst_offset] = bytebuff2;
|
||||||
|
-#ifdef DEVELMODE
|
||||||
|
- TIFFError ("", " Shift2 > Shift1\n");
|
||||||
|
+ TIFFError("", " Trailing bits %4"PRIu32" src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", trailing_bits, offset1 + full_bytes, dst_offset);
|
||||||
|
#endif
|
||||||
|
+ /* More than necessary bits are already copied into last destination buffer,
|
||||||
|
+ * only masking of last byte in destination buffer is necessary.*/
|
||||||
|
+ sect_buff[dst_offset] &= ((uint8_t)0xFF << (8 - trailing_bits));
|
||||||
|
}
|
||||||
|
- else
|
||||||
|
- {
|
||||||
|
- if (shift2 < shift1)
|
||||||
|
- {
|
||||||
|
- bytebuff2 = ((unsigned char)255 << (shift1 - shift2 - 1));
|
||||||
|
- sect_buff[dst_offset] &= bytebuff2;
|
||||||
|
-#ifdef DEVELMODE
|
||||||
|
- TIFFError ("", " Shift2 < Shift1\n");
|
||||||
|
-#endif
|
||||||
|
- }
|
||||||
|
-#ifdef DEVELMODE
|
||||||
|
- else
|
||||||
|
- TIFFError ("", " Shift2 == Shift1\n");
|
||||||
|
-#endif
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
#ifdef DEVELMODE
|
||||||
|
sprintf(&bitarray[28], " ");
|
||||||
|
sprintf(&bitarray[29], " ");
|
||||||
|
@@ -7062,7 +7042,7 @@ writeImageSections(TIFF *in, TIFF *out, struct image_data *image,
|
||||||
|
width = sections[i].x2 - sections[i].x1 + 1;
|
||||||
|
length = sections[i].y2 - sections[i].y1 + 1;
|
||||||
|
sectsize = (uint32_t)
|
||||||
|
- ceil((width * image->bps + 7) / (double)8) * image->spp * length;
|
||||||
|
+ ceil((width * image->bps * image->spp + 7) / (double)8) * length;
|
||||||
|
/* allocate a buffer if we don't have one already */
|
||||||
|
if (createImageSection(sectsize, sect_buff_ptr))
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.35.1
|
||||||
|
|
53
libtiff-CVE-2022-0924.patch
Normal file
53
libtiff-CVE-2022-0924.patch
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
From 224a9353b95896fcff787734a85352aa82eb7db5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: 4ugustus <wangdw.augustus@qq.com>
|
||||||
|
Date: Thu, 10 Mar 2022 08:48:00 +0000
|
||||||
|
Subject: [PATCH 3/3] fix heap buffer overflow in tiffcp (#278)
|
||||||
|
|
||||||
|
---
|
||||||
|
tools/tiffcp.c | 17 ++++++++++++++++-
|
||||||
|
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
|
||||||
|
index 1f88951..552d8fa 100644
|
||||||
|
--- a/tools/tiffcp.c
|
||||||
|
+++ b/tools/tiffcp.c
|
||||||
|
@@ -1661,12 +1661,27 @@ DECLAREwriteFunc(writeBufferToSeparateStrips)
|
||||||
|
tdata_t obuf;
|
||||||
|
tstrip_t strip = 0;
|
||||||
|
tsample_t s;
|
||||||
|
+ uint16_t bps = 0, bytes_per_sample;
|
||||||
|
|
||||||
|
obuf = limitMalloc(stripsize);
|
||||||
|
if (obuf == NULL)
|
||||||
|
return (0);
|
||||||
|
_TIFFmemset(obuf, 0, stripsize);
|
||||||
|
(void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||||
|
+ (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps);
|
||||||
|
+ if( bps == 0 )
|
||||||
|
+ {
|
||||||
|
+ TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample");
|
||||||
|
+ _TIFFfree(obuf);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ if( (bps % 8) != 0 )
|
||||||
|
+ {
|
||||||
|
+ TIFFError(TIFFFileName(out), "Error, cannot handle BitsPerSample that is not a multiple of 8");
|
||||||
|
+ _TIFFfree(obuf);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ bytes_per_sample = bps/8;
|
||||||
|
for (s = 0; s < spp; s++) {
|
||||||
|
uint32_t row;
|
||||||
|
for (row = 0; row < imagelength; row += rowsperstrip) {
|
||||||
|
@@ -1676,7 +1691,7 @@ DECLAREwriteFunc(writeBufferToSeparateStrips)
|
||||||
|
|
||||||
|
cpContigBufToSeparateBuf(
|
||||||
|
obuf, (uint8_t*) buf + row * rowsize + s,
|
||||||
|
- nrows, imagewidth, 0, 0, spp, 1);
|
||||||
|
+ nrows, imagewidth, 0, 0, spp, bytes_per_sample);
|
||||||
|
if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) {
|
||||||
|
TIFFError(TIFFFileName(out),
|
||||||
|
"Error, can't write strip %"PRIu32,
|
||||||
|
--
|
||||||
|
2.35.1
|
||||||
|
|
14
libtiff.spec
14
libtiff.spec
@ -1,7 +1,7 @@
|
|||||||
Summary: Library of functions for manipulating TIFF format image files
|
Summary: Library of functions for manipulating TIFF format image files
|
||||||
Name: libtiff
|
Name: libtiff
|
||||||
Version: 4.3.0
|
Version: 4.3.0
|
||||||
Release: 4%{?dist}
|
Release: 5%{?dist}
|
||||||
License: libtiff
|
License: libtiff
|
||||||
URL: http://www.simplesystems.org/libtiff/
|
URL: http://www.simplesystems.org/libtiff/
|
||||||
|
|
||||||
@ -14,6 +14,12 @@ Patch2: libtiff-CVE-2022-22844.patch
|
|||||||
# https://gitlab.com/libtiff/libtiff/-/issues/362
|
# https://gitlab.com/libtiff/libtiff/-/issues/362
|
||||||
Patch3: libtiff-CVE-2022-0561.patch
|
Patch3: libtiff-CVE-2022-0561.patch
|
||||||
Patch4: libtiff-CVE-2022-0562.patch
|
Patch4: libtiff-CVE-2022-0562.patch
|
||||||
|
# https://gitlab.com/libtiff/libtiff/-/commit/5e18004500cda10d9074bdb6166b054e95b659ed
|
||||||
|
Patch5: libtiff-CVE-2022-0865.patch
|
||||||
|
# https://gitlab.com/libtiff/libtiff/-/commit/232282fd8f9c21eefe8d2d2b96cdbbb172fe7b7c
|
||||||
|
Patch6: libtiff-CVE-2022-0891.patch
|
||||||
|
# https://gitlab.com/libtiff/libtiff/-/commit/408976c44ef0aad975e0d1b6c6dc80d60f9dc665
|
||||||
|
Patch7: libtiff-CVE-2022-0924.patch
|
||||||
|
|
||||||
BuildRequires: gcc, gcc-c++
|
BuildRequires: gcc, gcc-c++
|
||||||
BuildRequires: zlib-devel libjpeg-devel jbigkit-devel libzstd-devel libwebp-devel
|
BuildRequires: zlib-devel libjpeg-devel jbigkit-devel libzstd-devel libwebp-devel
|
||||||
@ -68,6 +74,9 @@ image files using the libtiff library.
|
|||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
%patch3 -p1
|
%patch3 -p1
|
||||||
%patch4 -p1
|
%patch4 -p1
|
||||||
|
%patch5 -p1
|
||||||
|
%patch6 -p1
|
||||||
|
%patch7 -p1
|
||||||
|
|
||||||
# Use build system's libtool.m4, not the one in the package.
|
# Use build system's libtool.m4, not the one in the package.
|
||||||
rm -f libtool.m4
|
rm -f libtool.m4
|
||||||
@ -172,6 +181,9 @@ find html -name 'Makefile*' | xargs rm
|
|||||||
%{_mandir}/man1/*
|
%{_mandir}/man1/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Mar 18 2022 Nikola Forró <nforro@redhat.com> - 4.3.0-5
|
||||||
|
- Fix CVE-2022-0865 (#2065359), CVE-2022-0891 (#2065389) and CVE-2022-0924 (#2064154)
|
||||||
|
|
||||||
* Tue Feb 15 2022 Nikola Forró <nforro@redhat.com> - 4.3.0-4
|
* Tue Feb 15 2022 Nikola Forró <nforro@redhat.com> - 4.3.0-4
|
||||||
- Fix CVE-2022-0561 (#2054499) and CVE-2022-0562 (#2054498)
|
- Fix CVE-2022-0561 (#2054499) and CVE-2022-0562 (#2054498)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user