BUG: TIFF over 2Gb

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Sam Fisher

BUG: TIFF over 2Gb

Post by Sam Fisher »

Environment: 32-bit platform, Visual Studio 2008

I have the TIFF file, which is more than 2Gb
ImageMagick could not process this file, because the blob-related (GetBlobSize, SeekBlob etc) functions uses fstat / fseek.
In the structure stat the field st_size has type signed long.
Therefore, we have error with types casting: long -> MagickSizeType (which means unsigned __int64) - sign expansion
The patch could look like this (checked for VS2008)
(compared IM 6.4.7 and trunk)

blob-private.h:

Code: Select all

4c4
< 
---
>   
7c7
< 
---
>   
9c9
< 
---
>   
63c63
< extern MagickExport const struct __stat64
---
> extern MagickExport const struct stat
blob.c

Code: Select all

119c119
<   struct __stat64
---
>   struct stat
1113c1113
< MagickExport const struct __stat64 *GetBlobProperties(const Image *image)
---
> MagickExport const struct stat *GetBlobProperties(const Image *image)
1165c1165
<       if (_fstat64(fileno(image->blob->file),&image->blob->properties) == 0)
---
>       if (fstat(fileno(image->blob->file),&image->blob->properties) == 0)
1178c1178
<       if (_fstat64(fileno(image->blob->file),&image->blob->properties) == 0)
---
>       if (fstat(fileno(image->blob->file),&image->blob->properties) == 0)
1186c1186
<       if (_fstat64(fileno(image->blob->file),&image->blob->properties) == 0)
---
>       if (fstat(fileno(image->blob->file),&image->blob->properties) == 0)
2362c2362
<        struct __stat64
---
>        struct stat
3277c3277
<       if (_fseeki64(image->blob->file,offset,whence) < 0)
---
>       if (fseek(image->blob->file,(off_t) offset,whence) < 0)
3619c3619
<       offset=_ftelli64(image->blob->file);
---
>       offset=ftell(image->blob->file);
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: BUG: TIFF over 2Gb

Post by magick »

We will get your patch into ImageMagick 6.4.7-9 within a day or two. Thanks.
Post Reply