tiff/tiff-CVE-2024-7006.patch

50 lines
2.2 KiB
Diff

Upstream:
3705f82b6483c7906cf08cd6b9dcdcd59c61d779
Index: tiff-4.6.0/libtiff/tif_dirinfo.c
===================================================================
--- tiff-4.6.0.orig/libtiff/tif_dirinfo.c
+++ tiff-4.6.0/libtiff/tif_dirinfo.c
@@ -887,7 +887,7 @@ const TIFFField *_TIFFFindOrRegisterFiel
if (fld == NULL)
{
fld = _TIFFCreateAnonField(tif, tag, dt);
- if (!_TIFFMergeFields(tif, fld, 1))
+ if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
return NULL;
}
Index: tiff-4.6.0/libtiff/tif_dirread.c
===================================================================
--- tiff-4.6.0.orig/libtiff/tif_dirread.c
+++ tiff-4.6.0/libtiff/tif_dirread.c
@@ -4260,11 +4260,9 @@ int TIFFReadDirectory(TIFF *tif)
dp->tdir_tag, dp->tdir_tag);
/* the following knowingly leaks the
anonymous field structure */
- if (!_TIFFMergeFields(
- tif,
- _TIFFCreateAnonField(tif, dp->tdir_tag,
- (TIFFDataType)dp->tdir_type),
- 1))
+ const TIFFField *fld = _TIFFCreateAnonField(
+ tif, dp->tdir_tag, (TIFFDataType)dp->tdir_type);
+ if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
{
TIFFWarningExtR(
tif, module,
@@ -5138,11 +5136,9 @@ int TIFFReadCustomDirectory(TIFF *tif, t
"Unknown field with tag %" PRIu16 " (0x%" PRIx16
") encountered",
dp->tdir_tag, dp->tdir_tag);
- if (!_TIFFMergeFields(
- tif,
- _TIFFCreateAnonField(tif, dp->tdir_tag,
- (TIFFDataType)dp->tdir_type),
- 1))
+ const TIFFField *fld = _TIFFCreateAnonField(
+ tif, dp->tdir_tag, (TIFFDataType)dp->tdir_type);
+ if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
{
TIFFWarningExtR(tif, module,
"Registering anonymous field with tag %" PRIu16