1
Index: tiff-3.8.2/tools/rgb2ycbcr.c
2
===================================================================
3
--- tiff-3.8.2.orig/tools/rgb2ycbcr.c 2009-07-12 14:37:00.967192158 -0400
4
+++ tiff-3.8.2/tools/rgb2ycbcr.c 2009-07-12 14:37:20.287192468 -0400
12
#define streq(a,b) (strcmp(a,b) == 0)
18
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
19
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
20
- raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32));
21
+ pixel_count = width * height;
23
+ /* XXX: Check the integer overflow. */
24
+ if (!width || !height || pixel_count / width != height) {
25
+ TIFFError(TIFFFileName(in),
26
+ "Malformed input file; "
27
+ "can't allocate buffer for raster of %lux%lu size",
28
+ (unsigned long)width, (unsigned long)height);
32
+ raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32),
35
- TIFFError(TIFFFileName(in), "No space for raster buffer");
36
+ TIFFError(TIFFFileName(in),
37
+ "Requested buffer size is %lu elements %lu each",
38
+ (unsigned long)pixel_count,
39
+ (unsigned long)sizeof(uint32));
43
if (!TIFFReadRGBAImage(in, width, height, raster, 0)) {
46
Index: tiff-3.8.2/tools/tiff2rgba.c
47
===================================================================
48
--- tiff-3.8.2.orig/tools/tiff2rgba.c 2009-07-12 14:37:00.975192458 -0400
49
+++ tiff-3.8.2/tools/tiff2rgba.c 2009-07-12 14:37:20.295191816 -0400
57
#define streq(a,b) (strcmp(a,b) == 0)
59
uint32* raster; /* retrieve RGBA image */
60
uint32 width, height; /* image width & height */
64
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
65
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
66
+ pixel_count = width * height;
68
+ /* XXX: Check the integer overflow. */
69
+ if (!width || !height || pixel_count / width != height) {
70
+ TIFFError(TIFFFileName(in),
71
+ "Malformed input file; can't allocate buffer for raster of %lux%lu size",
72
+ (unsigned long)width, (unsigned long)height);
76
rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
77
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
79
- raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32));
80
+ raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), "raster buffer");
82
- TIFFError(TIFFFileName(in), "No space for raster buffer");
83
+ TIFFError(TIFFFileName(in), "Requested buffer size is %lu elements %lu each",
84
+ (unsigned long)pixel_count, (unsigned long)sizeof(uint32));
92
- int pixel_count = width * height;
93
+ size_t count = pixel_count;
94
unsigned char *src, *dst;
96
src = (unsigned char *) raster;
97
dst = (unsigned char *) raster;
98
- while( pixel_count > 0 )