Crash bug when requesting image signature

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
DestroyedQuantum
Posts: 1
Joined: 2019-10-10T11:56:59-07:00
Authentication code: 1152

Crash bug when requesting image signature

Post by DestroyedQuantum »

Hello,

I am importing ImageMagick via wand in a python script :

Code: Select all

from wand.image import Image
Then I am using it to get data from images :

Code: Select all

try :
    with Image(filename='./my_image.png') as img:
        sys.stderr.write('SHA-256 message digest for the image pixel stream : ' + img.signature + '\n')
except :
    print("Oops! ",sys.exc_info()[0]," occured.")
but with a malformed image (this one for example https://github.com/fermads/codepress/bl ... umbers.png ) the exception is not handled properly and the script crashes with this message :

Code: Select all

    python: ../../magick/quantum.c:216: DestroyQuantumInfo: Assertion `quantum_info != (QuantumInfo *) NULL' failed.
Here is the doc about Wand Image signature : http://docs.wand-py.org/en/0.5.2/wand/i ... signature
Why is the exception not handled properly ?

ImageMagick version I use (I guess it is the default version in Ubuntu 18.04.2 LTS, which I am using) :

Code: Select all

$ identify --version
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Here I am looking for ImageMagick bug :

Code: Select all

$ identify -debug All line-numbers.png 
2019-05-31T16:20:42+02:00 0:00.000 0.000u 6.9.7 Configure identify-im6.q16[30840]: utility.c/ExpandFilenames/940/Configure
  Command line: identify {-debug} {All} {line-numbers.png}
2019-05-31T16:20:42+02:00 0:00.000 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/usr/share/ImageMagick-6/coder.xml"
2019-05-31T16:20:42+02:00 0:00.000 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.7//config-Q16/coder.xml"
2019-05-31T16:20:42+02:00 0:00.000 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/etc/ImageMagick-6/coder.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/usr/share/doc/imagemagick-6-common/htmlcoder.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/home/username/.config/ImageMagick/coder.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/home/username/.magick/coder.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: coder.c/LoadCoderCache/826/Configure
  Loading coder configuration file "/etc/ImageMagick-6/coder.xml" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Module identify-im6.q16[30840]: module.c/OpenModule/1288/Module
  Searching for module "PNG" using filename "png.la"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Module identify-im6.q16[30840]: module.c/GetMagickModulePath/558/Module
  Searching for coder module file "png.la" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Module identify-im6.q16[30840]: module.c/OpenModule/1297/Module
  Opening module at path "/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.7//modules-Q16/coders/png.la"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Module identify-im6.q16[30840]: module.c/OpenModule/1324/Module
  Method "RegisterPNGImage" in module "PNG" at address 0x7fac6c16f1c0
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Module identify-im6.q16[30840]: module.c/OpenModule/1338/Module
  Method "UnregisterPNGImage" in module "PNG" at address 0x7fac6c16f770
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Policy identify-im6.q16[30840]: policy.c/IsRightsAuthorized/580/Policy
  Domain: Path; rights=Read; pattern="line-numbers.png" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Blob identify-im6.q16[30840]: blob.c/OpenBlob/2593/Blob
    read 3 magic header bytes
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/usr/share/ImageMagick-6/magic.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.7//config-Q16/magic.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/etc/ImageMagick-6/magic.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/usr/share/doc/imagemagick-6-common/htmlmagic.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/home/username/.config/ImageMagick/magic.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: configure.c/GetConfigureOptions/685/Configure
  Searching for configure file: "/home/username/.magick/magic.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: magic.c/LoadMagicCache/794/Configure
  Loading magic configure file "/etc/ImageMagick-6/magic.xml" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Policy identify-im6.q16[30840]: policy.c/IsRightsAuthorized/580/Policy
  Domain: Coder; rights=Read; pattern="PNG" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Policy identify-im6.q16[30840]: policy.c/IsRightsAuthorized/580/Policy
  Domain: Path; rights=Read; pattern="line-numbers.png" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Blob identify-im6.q16[30840]: blob.c/OpenBlob/2593/Blob
    read 3 magic header bytes
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Coder identify-im6.q16[30840]: png.c/ReadPNGImage/3940/Coder
  Enter ReadPNGImage()
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Policy identify-im6.q16[30840]: policy.c/IsRightsAuthorized/580/Policy
  Domain: Path; rights=Read; pattern="line-numbers.png" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Blob identify-im6.q16[30840]: blob.c/OpenBlob/2593/Blob
    read 3 magic header bytes
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Coder identify-im6.q16[30840]: png.c/ReadOnePNGImage/2042/Coder
    Enter ReadOnePNGImage()
    IM version     = 6.9.7-4
    Libpng version = 1.6.34
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Coder identify-im6.q16[30840]: png.c/ReadOnePNGImage/2055/Coder
      Zlib version   = 1.2.11
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Coder identify-im6.q16[30840]: png.c/ReadOnePNGImage/2085/Coder
      Before reading:
      image->matte=0
      image->rendering_intent=2
      image->colorspace=13
      image->gamma=0.454545
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Coder identify-im6.q16[30840]: png.c/MagickPNGWarningHandler/1651/Coder
    libpng-1.6.34 warning: Image height exceeds user limit in IHDR
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/usr/share/ImageMagick-6/locale.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.7//config-Q16/locale.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/etc/ImageMagick-6/locale.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/usr/share/doc/imagemagick-6-common/htmllocale.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/home/username/.config/ImageMagick/locale.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/home/username/.magick/locale.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: locale.c/LoadLocaleCache/1177/Configure
  Loading locale configure file "/usr/share/ImageMagick-6/locale.xml" ...
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/usr/share/ImageMagick-6/english.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.7//config-Q16/english.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/etc/ImageMagick-6/english.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/usr/share/doc/imagemagick-6-common/htmlenglish.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/home/username/.config/ImageMagick/english.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Locale identify-im6.q16[30840]: locale.c/GetLocaleOptions/824/Locale
  Searching for locale file: "/home/username/.magick/english.xml"
2019-05-31T16:20:42+02:00 0:00.010 0.000u 6.9.7 Configure identify-im6.q16[30840]: locale.c/LoadLocaleCache/1177/Configure
  Loading locale configure file "/usr/share/ImageMagick-6/english.xml" ...
2019-05-31T16:20:42+02:00 0:00.020 0.000u 6.9.7 Exception identify-im6.q16[30840]: png.c/MagickPNGWarningHandler/1654/Exception
  Image height exceeds user limit in IHDR `line-numbers.png'
2019-05-31T16:20:42+02:00 0:00.020 0.000u 6.9.7 Coder identify-im6.q16[30840]: png.c/MagickPNGErrorHandler/1625/Coder
    libpng-1.6.34 error: Invalid IHDR data
2019-05-31T16:20:42+02:00 0:00.020 0.000u 6.9.7 Exception identify-im6.q16[30840]: png.c/MagickPNGErrorHandler/1628/Exception
  Invalid IHDR data `line-numbers.png'
identify: ../../magick/quantum.c :216 : DestroyQuantumInfo:  l'assertion « quantum_info != (QuantumInfo *) NULL » a échoué.
Abandon

Note : This question has been submitted to StackOverflow a few months ago : https://stackoverflow.com/questions/563 ... le-crashes
Post Reply