libtiff/SOURCES/0023-CVE-2022-22844-tiffset-fix-global-buffer-overflow-fo.patch

37 lines
1.6 KiB
Diff
Raw Normal View History

2022-11-08 06:48:26 +00:00
From 377a37d06f8ea753cba404cd6954b988ca861ad3 Mon Sep 17 00:00:00 2001
From: 4ugustus <wangdw.augustus@qq.com>
Date: Tue, 25 Jan 2022 16:25:28 +0000
Subject: [PATCH] (CVE-2022-22844) tiffset: fix global-buffer-overflow for
ASCII tags where count is required (fixes #355)
(cherry picked from commit 03047a26952a82daaa0792957ce211e0aa51bc64)
---
tools/tiffset.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/tiffset.c b/tools/tiffset.c
index 894c9f1f..e4b0d49f 100644
--- a/tools/tiffset.c
+++ b/tools/tiffset.c
@@ -134,9 +134,19 @@ main(int argc, char* argv[])
arg_index++;
if (TIFFFieldDataType(fip) == TIFF_ASCII) {
- if (TIFFSetField(tiff, TIFFFieldTag(fip), argv[arg_index]) != 1)
+ if(TIFFFieldPassCount( fip )) {
+ size_t len;
+ len = strlen(argv[arg_index]) + 1;
+ if (len > ((uint16)(~0)) || TIFFSetField(tiff, TIFFFieldTag(fip),
+ (uint16)len, argv[arg_index]) != 1)
fprintf( stderr, "Failed to set %s=%s\n",
TIFFFieldName(fip), argv[arg_index] );
+ } else {
+ if (TIFFSetField(tiff, TIFFFieldTag(fip),
+ argv[arg_index]) != 1)
+ fprintf( stderr, "Failed to set %s=%s\n",
+ TIFFFieldName(fip), argv[arg_index] );
+ }
} else if (TIFFFieldWriteCount(fip) > 0
|| TIFFFieldWriteCount(fip) == TIFF_VARIABLE) {
int ret = 1;