2019.01.22 15:11 "[Tiff] Possible bug in libTiff 4.0.9?", by SM

2019.01.28 23:19 "Re: [Tiff] libTiff Bug", by SM

I continue to get the segmentation violation after modifying the code as

per suggestions by Roger

 #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= (uint64)width * (uint64)height;
    uint32* raster= (uint32*)_TIFFmalloc(npixels *sizeof(uint32));
    if(raster == NULL)
        return 0;
    TIFFReadRGBAImage(tif, width, height, raster, 0);
}

Can you confirm this as a bug?

-upanita

On Tue, Apr 24, 2018 at 4:18 PM SM <skypemesm@gmail.com> wrote:

> Sorry forgot provide the code
>
> #include <tiffio.h>
> int main()
> {

>     TIFF *tif=TIFFOpen("Test_001.tif", "r");
>     uint64 width;
>     uint64 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);

> }
> This program crashes.
>
> Thanks,
> -SM
> On Tue, Apr 24, 2018 at 4:14 PM, SM <skypemesm@gmail.com> wrote:
>
>> I understand your concerns with the code. I was only writing a dummy
>> example to demonstrate the issue.
>>
>> See this:
>>
>> (gdb) r
>> Starting program: a.out
>>
>> Breakpoint 1, main () at main.c:4
>> 4 TIFF *tif=TIFFOpen("Test_001.tif", "r");
>> (gdb) n
>> 7 TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
>> (gdb)
>> 8 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
>> (gdb)
>> 9 uint64 npixels=width*height;
>> (gdb)

>> 10     uint32* raster=(uint32 *) _TIFFmalloc(npixels *sizeof(uint32));

>> (gdb)
>> 11 if (raster != NULL)
>> (gdb)
>> 12 TIFFReadRGBAImage(tif, width, height, raster, 0);
>> (gdb)
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00007ffff7b8b3e2 in putRGBcontig8bittile (img=img@entry=0x7fffffffdfb0,
>> cp=0x7ff885718014, cp@entry=0x7ff88a6d4010, 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=0x7fffffffdfb0,
>> cp=0x7ff885718014, cp@entry=0x7ff88a6d4010, 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\