2018.04.24 18:23 "Re: [Tiff] libTiff Bug", by SM
I changed the code to avoid the overflow
#include <tiffio.h>
int main()
{
TIFF *tif=TIFFOpen("Test_001.tif", "r");
uint32 width;
uint32 height;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
uint64 npixels=width*height;
uint32* raster=(uint32 *) _TIFFmalloc(npixels *sizeof(uint32));
TIFFReadRGBAImage(tif, width, height, raster, 0);
}
Crash continues to happen.
Reading symbols from a.out...done.
(gdb) b main.c:5
Breakpoint 1 at 0x400781: file main.c, line 5.
(gdb) r
Starting program: /mathworks/home/ugoswami/a.out
Breakpoint 1, main () at main.c:7
7 TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
(gdb) n
8 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
(gdb)
9 uint64 npixels=width*height;
(gdb)
10 uint32* raster=(uint32 *) _TIFFmalloc(npixels *sizeof(uint32));
(gdb)
11 TIFFReadRGBAImage(tif, width, height, raster, 0);
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b8b3e2 in putRGBcontig8bittile (img=img@entry=0x7fffffffdc60,
cp=0x7ffc85718014, cp@entry=0x7ffc8a6d4010, x=x@entry=0, y=y@entry=50175,
w=w@entry=512, h=268,
h@entry=512, fromskew=0, toskew=-86528,
pp=0x7ffff7eeb210
"\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\345\344\352\346\345\353\347\346\354\350\347\355\350\347\355\347\346\354\346\345\353\345\344\352\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\346\345\353\347\346\354\350\347\355\351\350\356\351\350\356\350\347\355\347\346\354\346\345\353\345\344\352\346\345\353\347\346\354\347\346\354\346\345\353\346\345\353\347\346\354\350\347\355\346\345\353\346\345\353\347\346\354\347\346\354\347\346\354\347\346\354\346\345\353\346\345\353\350\347\355\350\347\355\350\347\355\350\347\355\347\346\354\347\346\354\347\346\354\347\346\354\347\346\354\347\346\354\347",
<incomplete sequence \346>...)
at tif_getimage.c:1376
1376 UNROLL8(w, NOP,
(gdb) bt
#0 0x00007ffff7b8b3e2 in putRGBcontig8bittile (img=img@entry=0x7fffffffdc60,
cp=0x7ffc85718014, cp@entry=0x7ffc8a6d4010, x=x@entry=0, y=y@entry=50175,
w=w@entry=512,
h=268, h@entry=512, fromskew=0, toskew=-86528,
pp=0x7ffff7eeb210
"\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\350\347\355\345\344\352\346\345\353\347\346\354\350\347\355\350\347\355\347\346\354\346\345\353\345\344\352\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\351\346\355\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\350\345\354\346\345\353\347\346\354\350\347\355\351\350\356\351\350\356\350\347\355\347\346\354\346\345\353\345\344\352\346\345\353\347\346\354\347\346\354\346\345\353\346\345\353\347\346\354\350\347\355\346\345\353\346\345\353\347\346\354\347\346\354\347\346\354\347\346\354\346\345\353\346\345\353\350\347\355\350\347\355\350\347\355\350\347\355\347\346\354\347\346\354\347\346\354\347\346\354\347\346\354\347\346\354\347",
<incomplete sequence \346>...)
at tif_getimage.c:1376
#1 0x00007ffff7b90643 in gtTileContig (img=0x7fffffffdc60,
raster=0x7ffc85728010, w=86016, h=89600) at tif_getimage.c:673
#2 0x00007ffff7b92dfd in TIFFReadRGBAImageOriented (tif=<optimized out>,
rwidth=86016, rheight=<optimized out>, raster=0x7ffc85728010,
orientation=4, stop=0) at tif_getimage.c:514
#3 0x00000000004007f4 in main () at main.c:11
Thanks,
SM
On Mon, Apr 23, 2018 at 3:14 PM, Bob Friesenhahn <
bfriesen@simple.dallas.tx.us> wrote:
> On Mon, 23 Apr 2018, SM wrote:
>
> Dimension of the image: 86016-by-89600
>>
>
> That would lead to integer overflow!
>
> 86016*89600 ->