From 786a8b6fd1384c6e20c17729822d1f61ed569320 Mon Sep 17 00:00:00 2001
From: Hitendra Prajapati <hprajapati@mvista.com>
Date: Thu, 18 Aug 2022 10:46:30 +0530
Subject: [PATCH] CVE-2022-34526

Upstream-Status: Backport [https://gitlab.com/libtiff/libtiff/-/commit/275735d0354e39c0ac1dc3c0db2120d6f31d1990]
CVE: CVE-2022-34526
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>

---
 libtiff/tif_dirinfo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c
index 8565dfb..0f722a5 100644
--- a/libtiff/tif_dirinfo.c
+++ b/libtiff/tif_dirinfo.c
@@ -1157,6 +1157,9 @@ _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
 	    default:
 		return 1;
 	}
+	if( !TIFFIsCODECConfigured(tif->tif_dir.td_compression) ) {
+		return 0;
+	}
 	/* Check if codec specific tags are allowed for the current
 	 * compression scheme (codec) */
 	switch (tif->tif_dir.td_compression) {
