ReadXWDImage in coders/xwd.c in the XWD image parsing component of ImageMagick 7.0.8-41 Q16 allows attackers to cause a denial-of-service (divide-by-zero error) by crafting an XWD image file in which the header indicates neither LSB first nor MSB first.
### Prerequisites

- [x] I have written a descriptive issue title
- [x] I have verified that I am using the latest version of ImageMagick
- [x] I have searched [open](https://github.com/ImageMagick/ImageMagick/issues) and [closed](https://github.com/ImageMagick/ImageMagick/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported

### Description
When using `identify -verbose $FILE` on XWD files, it may emit FPE errors at multiple locations.

### Steps to Reproduce
* run `identify -verbose $FILE`
* ASAN messages may be like:

fpe_xwd.c:490_1.xwd
```
ASAN:DEADLYSIGNAL
=================================================================
==19029==ERROR: AddressSanitizer: FPE on unknown address 0x7f0623a03210 (pc 0x7f0623a03210 bp 0x000000000000 sp 0x7ffc86dbd220 T0)
    #0 0x7f0623a0320f  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x2720f)
    #1 0x7f0627deb295 in ReadXWDImage coders/xwd.c:490
    #2 0x7f06276d4854 in ReadImage MagickCore/constitute.c:547
    #3 0x7f06276d778b in ReadImages MagickCore/constitute.c:917
    #4 0x7f0626f69817 in IdentifyImageCommand MagickWand/identify.c:321
    #5 0x7f0626ffdde0 in MagickCommandGenesis MagickWand/mogrify.c:184
    #6 0x55c1ef27bf00 in MagickMain utilities/magick.c:149
    #7 0x55c1ef27c186 in main utilities/magick.c:180
    #8 0x7f062675ab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #9 0x55c1ef27b979 in _start (/home/hongxu/work/imagemagick/ImageMagick-asan/install/bin/magick+0x1979)
```

fpe_xwd.c:520_1.xwd
```
ASAN:DEADLYSIGNAL
=================================================================
==28450==ERROR: AddressSanitizer: FPE on unknown address 0x7f20a562e210 (pc 0x7f20a562e210 bp 0x000000000000 sp 0x7ffd19f36b80 T0)
    #0 0x7f20a562e20f  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x2720f)
    #1 0x7f20a9a166c9 in ReadXWDImage coders/xwd.c:520
    #2 0x7f20a92ff854 in ReadImage MagickCore/constitute.c:547
    #3 0x7f20a930278b in ReadImages MagickCore/constitute.c:917
    #4 0x7f20a8b94817 in IdentifyImageCommand MagickWand/identify.c:321
    #5 0x7f20a8c28de0 in MagickCommandGenesis MagickWand/mogrify.c:184
    #6 0x55b4ed9adf00 in MagickMain utilities/magick.c:149
    #7 0x55b4ed9ae186 in main utilities/magick.c:180
    #8 0x7f20a8385b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #9 0x55b4ed9ad979 in _start (/home/hongxu/work/imagemagick/ImageMagick-asan/install/bin/magick+0x1979)
```

### System Configuration

- ImageMagick version:7.0.8-41 Q16 x86_64 2019-04-14
- Environment (Operating system, version and so on): Ubuntu 18.04 LTS, x84_64
- Additional information: This was firstly detected in GraphicsMagick, but I found this also happens in ImageMagick 6/7.

POCs:
[im.zip](https://github.com/ImageMagick/ImageMagick/files/3077110/im.zip)


FPE errors when reading XWD images
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : FPE errors when reading XWD images
Issue date:

--- start body ---
### Prerequisites

- [x] I have written a descriptive issue title
- [x] I have verified that I am using the latest version of ImageMagick
- [x] I have searched [open](https://github.com/ImageMagick/ImageMagick/issues) and [closed](https://github.com/ImageMagick/ImageMagick/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported

### Description
When using `identify -verbose $FILE` on XWD files, it may emit FPE errors at multiple locations.

### Steps to Reproduce
* run `identify -verbose $FILE`
* ASAN messages may be like:

fpe_xwd.c:490_1.xwd
```
ASAN:DEADLYSIGNAL
=================================================================
==19029==ERROR: AddressSanitizer: FPE on unknown address 0x7f0623a03210 (pc 0x7f0623a03210 bp 0x000000000000 sp 0x7ffc86dbd220 T0)
    #0 0x7f0623a0320f  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x2720f)
    #1 0x7f0627deb295 in ReadXWDImage coders/xwd.c:490
    #2 0x7f06276d4854 in ReadImage MagickCore/constitute.c:547
    #3 0x7f06276d778b in ReadImages MagickCore/constitute.c:917
    #4 0x7f0626f69817 in IdentifyImageCommand MagickWand/identify.c:321
    #5 0x7f0626ffdde0 in MagickCommandGenesis MagickWand/mogrify.c:184
    #6 0x55c1ef27bf00 in MagickMain utilities/magick.c:149
    #7 0x55c1ef27c186 in main utilities/magick.c:180
    #8 0x7f062675ab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #9 0x55c1ef27b979 in _start (/home/hongxu/work/imagemagick/ImageMagick-asan/install/bin/magick+0x1979)
```

fpe_xwd.c:520_1.xwd
```
ASAN:DEADLYSIGNAL
=================================================================
==28450==ERROR: AddressSanitizer: FPE on unknown address 0x7f20a562e210 (pc 0x7f20a562e210 bp 0x000000000000 sp 0x7ffd19f36b80 T0)
    #0 0x7f20a562e20f  (/usr/lib/x86_64-linux-gnu/libX11.so.6+0x2720f)
    #1 0x7f20a9a166c9 in ReadXWDImage coders/xwd.c:520
    #2 0x7f20a92ff854 in ReadImage MagickCore/constitute.c:547
    #3 0x7f20a930278b in ReadImages MagickCore/constitute.c:917
    #4 0x7f20a8b94817 in IdentifyImageCommand MagickWand/identify.c:321
    #5 0x7f20a8c28de0 in MagickCommandGenesis MagickWand/mogrify.c:184
    #6 0x55b4ed9adf00 in MagickMain utilities/magick.c:149
    #7 0x55b4ed9ae186 in main utilities/magick.c:180
    #8 0x7f20a8385b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #9 0x55b4ed9ad979 in _start (/home/hongxu/work/imagemagick/ImageMagick-asan/install/bin/magick+0x1979)
```

### System Configuration

- ImageMagick version:7.0.8-41 Q16 x86_64 2019-04-14
- Environment (Operating system, version and so on): Ubuntu 18.04 LTS, x84_64
- Additional information: This was firstly detected in GraphicsMagick, but I found this also happens in ImageMagick 6/7.

POCs:
[im.zip](https://github.com/ImageMagick/ImageMagick/files/3077110/im.zip)


--- end body ---
