$NetBSD: patch-ab,v 1.1.2.2 2009/08/08 22:54:54 tron Exp $

Detect improper rows, columns, or depth.
Fixes CVE-2008-1097 "Memory corruption in ImageMagick's PCX coder".

http://cvs.graphicsmagick.org/cgi-bin/cvsweb.cgi/GraphicsMagick/coders/pcx.c.diff?r1=1.135;r2=1.136

--- coders/pcx.c.orig	2008-11-07 17:36:01.000000000 +0000
+++ coders/pcx.c
@@ -302,6 +302,9 @@ static Image *ReadPCXImage(const ImageIn
     */
     image->columns=(pcx_info.right-pcx_info.left)+1;
     image->rows=(pcx_info.bottom-pcx_info.top)+1;
+    if ((image->columns == 0) || (image->rows == 0) ||
+        (pcx_info.bits_per_pixel == 0))
+      ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
     image->depth=pcx_info.bits_per_pixel <= 8 ? 8 : QuantumDepth;
     image->units=PixelsPerInchResolution;
     image->x_resolution=pcx_info.horizontal_resolution;
