Page 1 of 1

Image Fails to Load in Newer Versions of 64-bit ImageMagick

Posted: 2008-08-29T18:30:37-07:00
by pcorliss
I have a user submitted image that is causing me a lot of trouble. We experience the problem on machines running ImageMagick 6.3.4 and higher and compiled and run on a 64-bit OS. 32-bit OS machines don't seem to run into the problem at all. Unfortunately there are other images in our system that require a version greater than 6.3.4 so we can't just downgrade.

#Original Image
http://alttab.org/corruptImage.bmp

#Example Output
[dev@manet ~]$ /foo/apps/imagemagick-6.3.3/bin/identify corruptImage.bmp
corruptImage.bmp BMP 176x112 176x112+0+0 DirectClass 16-bit 38.5645kb
[dev@manet ~]$ /foo/apps/imagemagick-6.3.4/bin/identify corruptImage.bmp
identify: Memory allocation failed `corruptImage.bmp'.
[dev@manet ~]$ /foo/apps/imagemagick-6.3.5/bin/identify corruptImage.bmp
File size limit exceeded
[dev@manet ~]$ /foo/apps/imagemagick-6.3.9/bin/identify corruptImage.bmp
File size limit exceeded
[dev@manet ~]$ /foo/apps/imagemagick-6.4.2/bin/identify corruptImage.bmp
File size limit exceeded

#Bad Debug Output
[dev@manet ~]$ /foo/apps/imagemagick-6.4.2/bin/identify -debug All corruptImage.bmp
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: utility.c/unknown/809/Configure
Command line: /foo/apps/imagemagick-6.4.2/bin/identify {-debug} {All} {corruptImage.bmp}
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/share/ImageMagick-6.4.2/config/coder.xml"
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/lib/ImageMagick-6.4.2/config/coder.xml"
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/share/doc/ImageMagick-6.4.2/coder.xml"
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/share/ImageMagick-6.4.2/coder.xml"
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/home/dev/.magick/coder.xml"
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "coder.xml"
2008-08-29T18:15:52-07:00 0:01 0.000u 6.4.2 Configure identify[16108]: coder.c/unknown/634/Configure
Loading coder map "/foo/apps/imagemagick-6.4.2/share/ImageMagick-6.4.2/config/coder.xml" ...
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Module identify[16108]: module.c/unknown/1077/Module
Searching for module "BMP" using filename "bmp.la"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Module identify[16108]: module.c/unknown/479/Module
Searching for coder module file "bmp.la" ...
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Module identify[16108]: module.c/unknown/1097/Module
Opening module at path "/foo/apps/imagemagick-6.4.2/lib/ImageMagick-6.4.2/modules-Q16/coders/bmp.la"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Module identify[16108]: module.c/unknown/1131/Module
Method "RegisterBMPImage" in module "BMP" at address 0x2a95a88560
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Module identify[16108]: module.c/unknown/1146/Module
Method "UnregisterBMPImage" in module "BMP" at address 0x2a95a88670
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Blob identify[16108]: blob.c/unknown/2342/Blob
read 3 magic header bytes
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Cache identify[16108]: cache.c/unknown/2191/Cache
destroy
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/share/ImageMagick-6.4.2/config/magic.xml"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/lib/ImageMagick-6.4.2/config/magic.xml"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/share/doc/ImageMagick-6.4.2/magic.xml"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/foo/apps/imagemagick-6.4.2/share/ImageMagick-6.4.2/magic.xml"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "/home/dev/.magick/magic.xml"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Configure identify[16108]: configure.c/unknown/528/Configure
Searching for configure file: "magic.xml"
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Configure identify[16108]: magic.c/unknown/679/Configure
Loading magic map "/foo/apps/imagemagick-6.4.2/share/ImageMagick-6.4.2/config/magic.xml" ...
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Blob identify[16108]: blob.c/unknown/2342/Blob
read 3 magic header bytes
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Cache identify[16108]: cache.c/unknown/2191/Cache
destroy
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Blob identify[16108]: blob.c/unknown/2342/Blob
read 3 magic header bytes
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Coder identify[16108]: bmp.c/unknown/601/Coder
Magick: BM
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Coder identify[16108]: bmp.c/unknown/611/Coder
BMP size: 40
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Coder identify[16108]: bmp.c/unknown/657/Coder
Format: MS Windows bitmap
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Coder identify[16108]: bmp.c/unknown/659/Coder
Geometry: 176x4294967184
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Coder identify[16108]: bmp.c/unknown/661/Coder
Bits per pixel: 16
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Coder identify[16108]: bmp.c/unknown/685/Coder
Compression: BI_BITFIELDS
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Coder identify[16108]: bmp.c/unknown/707/Coder
Number of colors: 0
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Resource identify[16108]: resource.c/unknown/220/Resource
Area: 5.5tb/5.5tb/7.7155gb
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Resource identify[16108]: resource.c/unknown/220/Resource
Disk: 5.5tb/5.5tb/-1b
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Resource identify[16108]: resource.c/unknown/401/Resource

2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Exception identify[16108]: configure.c/unknown/228/Exception
no such element in list `MAGICK_TEMPORARY_PATH'
2008-08-29T18:15:52-07:00 0:01 0.010u 6.4.2 Resource identify[16108]: resource.c/unknown/429/Resource
/tmp/magick-XXXjpPH1
2008-08-29T18:15:52-07:00 0:01 0.020u 6.4.2 Resource identify[16108]: resource.c/unknown/220/Resource
File: 1b/1b/7.7e+02b
2008-08-29T18:15:52-07:00 0:01 0.020u 6.4.2 Cache identify[16108]: cache.c/unknown/3439/Cache
extend corruptImage.bmp[0] (/tmp/magick-XXXjpPH1[4], disk, 5.5tb)
File size limit exceeded

#Good Debug Output
[dev@rmagick2 ~]$ identify -debug All corruptImage.bmp
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: utility.c/unknown/809/Configure
Command line: identify {-debug} {All} {corruptImage.bmp}
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/lib/ImageMagick-6.3.9/config/coder.xml"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/share/ImageMagick-6.3.9/config/coder.xml"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/share/doc/ImageMagick-6.3.9/coder.xml"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/share/ImageMagick-6.3.9/coder.xml"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/home/dev/.magick/coder.xml"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "coder.xml"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Configure identify[2269]: coder.c/unknown/634/Configure
Loading coder map "/foo/apps/imagemagick-6.3.9/share/ImageMagick-6.3.9/config/coder.xml" ...
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Module identify[2269]: module.c/unknown/1074/Module
Searching for module "BMP" using filename "bmp.la"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Module identify[2269]: module.c/unknown/479/Module
Searching for coder module file "bmp.la" ...
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Module identify[2269]: module.c/unknown/1094/Module
Opening module at path "/foo/apps/imagemagick-6.3.9/lib/ImageMagick-6.3.9/modules-Q16/coders/bmp.la"
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Module identify[2269]: module.c/unknown/1128/Module
Method "RegisterBMPImage" in module "BMP" at address 0x26af80
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Module identify[2269]: module.c/unknown/1143/Module
Method "UnregisterBMPImage" in module "BMP" at address 0x26af30
2008-08-29T18:19:44-07:00 0:01 0.000u 6.3.9 Blob identify[2269]: blob.c/unknown/2356/Blob
read 3 magic header bytes
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Cache identify[2269]: cache.c/unknown/2162/Cache
destroy
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/lib/ImageMagick-6.3.9/config/magic.xml"
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/share/ImageMagick-6.3.9/config/magic.xml"
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/share/doc/ImageMagick-6.3.9/magic.xml"
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/foo/apps/imagemagick-6.3.9/share/ImageMagick-6.3.9/magic.xml"
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "/home/dev/.magick/magic.xml"
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Configure identify[2269]: configure.c/unknown/482/Configure
Searching for configure file: "magic.xml"
2008-08-29T18:19:44-07:00 0:01 0.010u 6.3.9 Configure identify[2269]: magic.c/unknown/679/Configure
Loading magic map "/foo/apps/imagemagick-6.3.9/share/ImageMagick-6.3.9/config/magic.xml" ...
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Blob identify[2269]: blob.c/unknown/2356/Blob
read 3 magic header bytes
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Cache identify[2269]: cache.c/unknown/2162/Cache
destroy
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Blob identify[2269]: blob.c/unknown/2356/Blob
read 3 magic header bytes
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/601/Coder
Magick: BM
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/611/Coder
BMP size: 40
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/657/Coder
Format: MS Windows bitmap
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/659/Coder
Geometry: 176x-112
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/661/Coder
Bits per pixel: 16
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/685/Coder
Compression: BI_BITFIELDS
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/707/Coder
Number of colors: 0
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Resource identify[2269]: resource.c/unknown/219/Resource
Area: 154kb/154kb/245.414mb
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Resource identify[2269]: resource.c/unknown/219/Resource
Memory: 154kb/154kb/184.061mb
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Cache identify[2269]: cache.c/unknown/3525/Cache
open corruptImage.bmp[0] (anonymous memory, 176x112 154kb)
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Coder identify[2269]: bmp.c/unknown/916/Coder
Reading pixels (39424 bytes)
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Resource identify[2269]: resource.c/unknown/219/Resource
Area: 154kb/154kb/245.414mb
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Resource identify[2269]: resource.c/unknown/219/Resource
Memory: 154kb/308kb/184.061mb
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Cache identify[2269]: cache.c/unknown/3525/Cache
open corruptImage.bmp[0] (anonymous memory, 176x112 154kb)
2008-08-29T18:19:44-07:00 0:01 0.020u 6.3.9 Cache identify[2269]: cache.c/unknown/1928/Cache
memory => memory
2008-08-29T18:19:44-07:00 0:01 0.030u 6.3.9 Resource identify[2269]: resource.c/unknown/834/Resource
Memory: 154kb/154kb/184.061mb
2008-08-29T18:19:44-07:00 0:01 0.030u 6.3.9 Cache identify[2269]: cache.c/unknown/2162/Cache
destroy corruptImage.bmp[0]
corruptImage.bmp BMP 176x112 176x112+0+0 DirectClass 8-bit 38.5645kb
2008-08-29T18:19:44-07:00 0:01 0.030u 6.3.9 Resource identify[2269]: resource.c/unknown/834/Resource
Memory: 154kb/0b/184.061mb
2008-08-29T18:19:44-07:00 0:01 0.030u 6.3.9 Cache identify[2269]: cache.c/unknown/2162/Cache
destroy corruptImage.bmp[0]

Re: Image Fails to Load in Newer Versions of 64-bit ImageMagick

Posted: 2008-08-29T19:11:41-07:00
by magick
To fix the problem you reported, in coders/bmp.c, change
  • bmp_info.width=(long) ReadBlobLSBLong(image);
    bmp_info.height=(long) ReadBlobLSBLong(image);

to
  • bmp_info.width=(int) ReadBlobLSBLong(image);
    bmp_info.height=(int) ReadBlobLSBLong(image);

Re: Image Fails to Load in Newer Versions of 64-bit ImageMagick

Posted: 2008-08-29T19:41:22-07:00
by pcorliss
Excellent, that does indeed work. Could this potentially cause other problems?