about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-06-28 02:15:02 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-06-28 02:15:02 +0000
commit42f26661aef4474a07544cf24187e00f204d1023 (patch)
treee50cbbe0696a839344ae4c33398e4bb8e1c84e7a
parent9174fafa11c2c01c48066c4dd4dcf2790ba1f6c9 (diff)
downloadnetpbm-mirror-42f26661aef4474a07544cf24187e00f204d1023.tar.gz
netpbm-mirror-42f26661aef4474a07544cf24187e00f204d1023.tar.xz
netpbm-mirror-42f26661aef4474a07544cf24187e00f204d1023.zip
Release 10.82.03
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3282 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/pstopnm.c19
-rw-r--r--doc/HISTORY8
-rw-r--r--editor/pbmmask.c5
-rw-r--r--version.mk2
4 files changed, 27 insertions, 7 deletions
diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c
index e19a0fa4..94219c2c 100644
--- a/converter/other/pstopnm.c
+++ b/converter/other/pstopnm.c
@@ -309,10 +309,14 @@ computeSizeResBlind(unsigned int        const xmax,
                     unsigned int        const imageHeight,
                     bool                const nocrop,
                     struct Dimensions * const imageDimP) {
-    
-    imageDimP->xres = imageDimP->yres = MIN(xmax * 72 / imageWidth, 
-                                            ymax * 72 / imageHeight);
-    
+
+    if (imageWidth == 0 || imageHeight == 0) {
+        imageDimP->xres = imageDimP->yres = 72;
+    } else {
+        imageDimP->xres = imageDimP->yres = MIN(xmax * 72 / imageWidth,
+                                                ymax * 72 / imageHeight);
+    }
+
     if (nocrop) {
         imageDimP->xsize = xmax;
         imageDimP->ysize = ymax;
@@ -362,10 +366,13 @@ computeSizeRes(struct CmdlineInfo  const cmdline,
         imageDimP->xres = imageDimP->yres = cmdline.dpi;
         imageDimP->xsize = ROUNDU(cmdline.dpi * sx / 72.0);
         imageDimP->ysize = ROUNDU(cmdline.dpi * sy / 72.0);
-    } else  if (cmdline.xsize || cmdline.ysize)
+    } else  if (cmdline.xsize || cmdline.ysize) {
+        if (sx == 0 || sy == 0)
+            pm_error("Input image is zero size; we cannot satisfy your "
+                     "produce your requested output dimensions");
         computeSizeResFromSizeSpec(cmdline.xsize, cmdline.ysize, sx, sy,
                                    imageDimP);
-    else 
+    } else
         computeSizeResBlind(cmdline.xmax, cmdline.ymax, sx, sy, cmdline.nocrop,
                             imageDimP);
 
diff --git a/doc/HISTORY b/doc/HISTORY
index d3cb991f..bd2b49a7 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,6 +4,14 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
+18.06.28 BJH  Release 10.82.03
+
+              pbmmask: Fix invalid memory reference with zero-dimension
+              input image.  Broken in primordial Netpbm, ca 1989.
+
+              pstopnm: Fix divide-by-zero crash when Postscript input says
+              the image has zero size.
+
 18.06.27 BJH  Release 10.82.02
 
               Pngtopam: Fix bogus warning of non-square pixels when image does
diff --git a/editor/pbmmask.c b/editor/pbmmask.c
index 21ada6b9..25c71226 100644
--- a/editor/pbmmask.c
+++ b/editor/pbmmask.c
@@ -143,6 +143,11 @@ main(int argc, char * argv[]) {
         pm_usage( usage );
 
     bits = pbm_readpbm( ifp, &cols, &rows );
+
+    if (cols == 0 || rows == 0)
+        pm_error("Image contains no pixels, so there is no such thing "
+                 "as background and foreground");
+
     pm_close( ifp );
     mask = pbm_allocarray( cols, rows );
 
diff --git a/version.mk b/version.mk
index 62f630cb..79c2b14a 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 82
-NETPBM_POINT_RELEASE = 2
+NETPBM_POINT_RELEASE = 3