1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
From 0ac97aa7a5bffddd88f7cdbe517264e9db3f5bd5 Mon Sep 17 00:00:00 2001
From: Lee Howard <faxguy@howardsilvan.com>
Date: Fri, 5 Sep 2025 21:42:35 +0000
Subject: [PATCH] tiffcrop: fix double-free and memory leak exposed by issue
#721
CVE: CVE-2025-8961
Upstream-Status: Backport [https://gitlab.com/libtiff/libtiff/-/commit/0ac97aa7a5bffddd88f7cdbe517264e9db3f5bd5]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
tools/tiffcrop.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
index ae414efc..be250cc9 100644
--- a/tools/tiffcrop.c
+++ b/tools/tiffcrop.c
@@ -1072,6 +1072,7 @@ static int readContigTilesIntoBuffer(TIFF *in, uint8_t *buf,
"Unable to extract row %" PRIu32
" from tile %" PRIu32,
row, TIFFCurrentTile(in));
+ _TIFFfree(tilebuf);
return 1;
}
break;
@@ -1086,6 +1087,7 @@ static int readContigTilesIntoBuffer(TIFF *in, uint8_t *buf,
"Unable to extract row %" PRIu32
" from tile %" PRIu32,
row, TIFFCurrentTile(in));
+ _TIFFfree(tilebuf);
return 1;
}
break;
@@ -1098,6 +1100,7 @@ static int readContigTilesIntoBuffer(TIFF *in, uint8_t *buf,
"Unable to extract row %" PRIu32
" from tile %" PRIu32,
row, TIFFCurrentTile(in));
+ _TIFFfree(tilebuf);
return 1;
}
break;
@@ -1110,6 +1113,7 @@ static int readContigTilesIntoBuffer(TIFF *in, uint8_t *buf,
"Unable to extract row %" PRIu32
" from tile %" PRIu32,
row, TIFFCurrentTile(in));
+ _TIFFfree(tilebuf);
return 1;
}
break;
@@ -1124,12 +1128,14 @@ static int readContigTilesIntoBuffer(TIFF *in, uint8_t *buf,
"Unable to extract row %" PRIu32
" from tile %" PRIu32,
row, TIFFCurrentTile(in));
+ _TIFFfree(tilebuf);
return 1;
}
break;
default:
TIFFError("readContigTilesIntoBuffer",
"Unsupported bit depth %" PRIu16, bps);
+ _TIFFfree(tilebuf);
return 1;
}
}
@@ -2901,7 +2907,7 @@ int main(int argc, char *argv[])
}
/* If we did not use the read buffer as the crop buffer */
- if (read_buff)
+ if (read_buff && read_buff != crop_buff)
_TIFFfree(read_buff);
if (crop_buff)
|