File GraphicsMagick-CVE-2014-9815.patch of Package GraphicsMagick.7727
Index: GraphicsMagick-1.2.5/coders/wpg.c
===================================================================
--- GraphicsMagick-1.2.5.orig/coders/wpg.c 2016-06-20 12:22:18.043000670 +0200
+++ GraphicsMagick-1.2.5/coders/wpg.c 2016-06-20 12:23:29.284160798 +0200
@@ -954,6 +954,8 @@ static Image *ReadWPGImage(const ImageIn
case 0x0B: /* bitmap type 1 */
BitmapHeader1.Width=ReadBlobLSBShort(image);
BitmapHeader1.Heigth=ReadBlobLSBShort(image);
+ if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Heigth == 0))
+ ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
BitmapHeader1.Depth=ReadBlobLSBShort(image);
BitmapHeader1.HorzRes=ReadBlobLSBShort(image);
BitmapHeader1.VertRes=ReadBlobLSBShort(image);
@@ -1005,6 +1007,8 @@ static Image *ReadWPGImage(const ImageIn
BitmapHeader2.UpRightY=ReadBlobLSBShort(image);
BitmapHeader2.Width=ReadBlobLSBShort(image);
BitmapHeader2.Heigth=ReadBlobLSBShort(image);
+ if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Heigth == 0))
+ ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
BitmapHeader2.Depth=ReadBlobLSBShort(image);
BitmapHeader2.HorzRes=ReadBlobLSBShort(image);
BitmapHeader2.VertRes=ReadBlobLSBShort(image);
@@ -1187,6 +1191,8 @@ static Image *ReadWPGImage(const ImageIn
case 0x0E:
Bitmap2Header1.Width=ReadBlobLSBShort(image);
Bitmap2Header1.Heigth=ReadBlobLSBShort(image);
+ if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Heigth == 0))
+ ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
Bitmap2Header1.Depth=ReadBlobByte(image);
Bitmap2Header1.Compression=ReadBlobByte(image);