fix CVE-2022-0865

(cherry picked from commit 86390d1a4df3afa9c91b26bf68f8031a3c132db5)
This commit is contained in:
yangcheng1203 2022-03-29 16:08:33 +08:00 committed by openeuler-sync-bot
parent 1e8b25a4ca
commit 74e68cb40f
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,34 @@
From a1c933dabd0e1c54a412f3f84ae0aa58115c6067 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] 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 7ffe885..ca1ca43 100644
--- a/libtiff/tif_jbig.c
+++ b/libtiff/tif_jbig.c
@@ -208,6 +208,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.27.0

View File

@ -1,6 +1,6 @@
Name: libtiff
Version: 4.1.0
Release: 8
Release: 9
Summary: TIFF Library and Utilities
License: libtiff
URL: https://www.simplesystems.org/libtiff/
@ -17,6 +17,7 @@ Patch6007: backport-0003-CVE-2022-22844.patch
Patch6008: backport-CVE-2022-0891.patch
Patch6009: backport-CVE-2022-0908.patch
Patch6010: backport-CVE-2022-0907.patch
Patch6011: backport-CVE-2022-0865.patch
BuildRequires: gcc gcc-c++ zlib-devel libjpeg-devel jbigkit-devel
BuildRequires: libtool automake autoconf pkgconfig git
@ -123,6 +124,9 @@ find html -name 'Makefile*' | xargs rm
%exclude %{_datadir}/html/man/tiffgt.1.html
%changelog
* Tue Mar 29 2022 yangcheng <yangcheng87@h-partners.com> - 4.1.0-9
- fix CVE-2022-0865
* Tue Mar 28 2022 yangcheng <yangcheng87@h-partners.com> - 4.1.0-8
- fix CVE-2022-0907