1 |
ssuominen 10/02/26 20:31:34 |
2 |
|
3 |
Added: tiff-3.9.2-CVE-2009-2347.patch |
4 |
Log: |
5 |
Fix CVE-2009-2347 again wrt security #307001. |
6 |
(Portage version: 2.2_rc63/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 media-libs/tiff/files/tiff-3.9.2-CVE-2009-2347.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-libs/tiff/files/tiff-3.9.2-CVE-2009-2347.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-libs/tiff/files/tiff-3.9.2-CVE-2009-2347.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: tiff-3.9.2-CVE-2009-2347.patch |
15 |
=================================================================== |
16 |
http://bugs.gentoo.org/show_bug.cgi?id=307001 |
17 |
http://bugzilla.maptools.org/show_bug.cgi?id=2079 |
18 |
|
19 |
--- tools/tiff2rgba.c |
20 |
+++ tools/tiff2rgba.c |
21 |
@@ -125,6 +125,17 @@ |
22 |
return (0); |
23 |
} |
24 |
|
25 |
+static tsize_t |
26 |
+multiply(tsize_t m1, tsize_t m2) |
27 |
+{ |
28 |
+ tsize_t prod = m1 * m2; |
29 |
+ |
30 |
+ if (m1 && prod / m1 != m2) |
31 |
+ prod = 0; /* overflow */ |
32 |
+ |
33 |
+ return prod; |
34 |
+} |
35 |
+ |
36 |
static int |
37 |
cvt_by_tile( TIFF *in, TIFF *out ) |
38 |
|
39 |
@@ -134,6 +145,7 @@ |
40 |
uint32 tile_width, tile_height; |
41 |
uint32 row, col; |
42 |
uint32 *wrk_line; |
43 |
+ tsize_t raster_size; |
44 |
int ok = 1; |
45 |
|
46 |
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); |
47 |
@@ -151,7 +163,14 @@ |
48 |
/* |
49 |
* Allocate tile buffer |
50 |
*/ |
51 |
- raster = (uint32*)_TIFFmalloc(tile_width * tile_height * sizeof (uint32)); |
52 |
+ raster_size = multiply(multiply(tile_width, tile_height), sizeof (uint32)); |
53 |
+ if (!raster_size) { |
54 |
+ TIFFError(TIFFFileName(in), |
55 |
+ "Can't allocate buffer for raster of size %lux%lu", |
56 |
+ (unsigned long) tile_width, (unsigned long) tile_height); |
57 |
+ return (0); |
58 |
+ } |
59 |
+ raster = (uint32*)_TIFFmalloc(raster_size); |
60 |
if (raster == 0) { |
61 |
TIFFError(TIFFFileName(in), "No space for raster buffer"); |
62 |
return (0); |
63 |
@@ -159,7 +178,7 @@ |
64 |
|
65 |
/* |
66 |
* Allocate a scanline buffer for swapping during the vertical |
67 |
- * mirroring pass. |
68 |
+ * mirroring pass. (Request can't overflow given prior checks.) |
69 |
*/ |
70 |
wrk_line = (uint32*)_TIFFmalloc(tile_width * sizeof (uint32)); |
71 |
if (!wrk_line) { |
72 |
@@ -236,6 +255,7 @@ |
73 |
uint32 width, height; /* image width & height */ |
74 |
uint32 row; |
75 |
uint32 *wrk_line; |
76 |
+ tsize_t raster_size; |
77 |
int ok = 1; |
78 |
|
79 |
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); |
80 |
@@ -251,7 +271,14 @@ |
81 |
/* |
82 |
* Allocate strip buffer |
83 |
*/ |
84 |
- raster = (uint32*)_TIFFmalloc(width * rowsperstrip * sizeof (uint32)); |
85 |
+ raster_size = multiply(multiply(width, rowsperstrip), sizeof (uint32)); |
86 |
+ if (!raster_size) { |
87 |
+ TIFFError(TIFFFileName(in), |
88 |
+ "Can't allocate buffer for raster of size %lux%lu", |
89 |
+ (unsigned long) width, (unsigned long) rowsperstrip); |
90 |
+ return (0); |
91 |
+ } |
92 |
+ raster = (uint32*)_TIFFmalloc(raster_size); |
93 |
if (raster == 0) { |
94 |
TIFFError(TIFFFileName(in), "No space for raster buffer"); |
95 |
return (0); |
96 |
@@ -259,7 +286,7 @@ |
97 |
|
98 |
/* |
99 |
* Allocate a scanline buffer for swapping during the vertical |
100 |
- * mirroring pass. |
101 |
+ * mirroring pass. (Request can't overflow given prior checks.) |
102 |
*/ |
103 |
wrk_line = (uint32*)_TIFFmalloc(width * sizeof (uint32)); |
104 |
if (!wrk_line) { |