about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-09-29 02:44:42 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-09-29 02:44:42 +0000
commitacf1c3cd5f989ff0e2a3895f35875c918b4c3eb8 (patch)
treeeec649bf9126f527b3b1f5bb128121e8280a49cc
parent84c6e11810783388e5be22ab80a5dafe523f20db (diff)
downloadnetpbm-mirror-acf1c3cd5f989ff0e2a3895f35875c918b4c3eb8.tar.gz
netpbm-mirror-acf1c3cd5f989ff0e2a3895f35875c918b4c3eb8.tar.xz
netpbm-mirror-acf1c3cd5f989ff0e2a3895f35875c918b4c3eb8.zip
Release 10.47.70
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@3345 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/pstopnm.c24
-rw-r--r--doc/HISTORY15
-rw-r--r--editor/pbmmask.c5
-rw-r--r--lib/libpbmfont.c37
-rw-r--r--version.mk2
5 files changed, 73 insertions, 10 deletions
diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c
index ba1470b0..0e91ad9c 100644
--- a/converter/other/pstopnm.c
+++ b/converter/other/pstopnm.c
@@ -275,9 +275,13 @@ computeSizeResBlind(unsigned int   const xmax,
                     unsigned int * const xresP,
                     unsigned int * const yresP) {
 
-    *xresP = *yresP = MIN(xmax * 72 / imageWidth, 
-                          ymax * 72 / imageHeight);
-    
+    if (imageWidth == 0 || imageHeight == 0) {
+        *xresP = *yresP = 72;
+    } else {
+        *xresP = *yresP = MIN(xmax * 72 / imageWidth,
+                              ymax * 72 / imageHeight);
+    }
+
     if (nocrop) {
         *xsizeP = xmax;
         *ysizeP = ymax;
@@ -335,10 +339,13 @@ computeSizeRes(struct cmdlineInfo const cmdline,
         *xresP = *yresP = cmdline.dpi;
         *xsizeP = (int) (cmdline.dpi * sx / 72 + 0.5);
         *ysizeP = (int) (cmdline.dpi * sy / 72 + 0.5);
-    } 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,
                                    xsizeP, ysizeP, xresP, yresP);
-    else 
+    } else
         computeSizeResBlind(cmdline.xmax, cmdline.ymax, sx, sy, cmdline.nocrop,
                             xsizeP, ysizeP, xresP, yresP);
 
@@ -886,7 +893,12 @@ main(int argc, char ** argv) {
 
     computeSizeRes(cmdline, orientation, bordered_box, 
                    &xsize, &ysize, &xres, &yres);
-    
+
+    if (xres == 0)
+        xres = 1;
+    if (yres == 0)
+        yres = 1;
+
     pstrans = computePstrans(bordered_box, orientation,
                              xsize, ysize, xres, yres);
 
diff --git a/doc/HISTORY b/doc/HISTORY
index 83dec462..45bb971a 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,6 +4,21 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
+18.09.29 BJH  Release 10.47.70
+
+              pstopnm: Fix divide-by-zero crash when Postscript input says
+              the image has zero size.
+
+              pstopnm: Fix divide-by-zero crash when computed resolution
+              rounds down to zero dots per inch.
+
+              pbmtext; libnetpbm BDF font processing: fix invalid memory
+              reference when BDF font file has invalid syntax.  Broken
+              in primordial Netpbm, ca 1993.
+
+              pbmmask: Fix invalid memory reference with zero-dimension
+              input image.  Broken in primordial Netpbm, ca 1989.
+
 18.06.27 BJH  Release 10.47.69
 
               ilbmtoppm: Fix bug: may fail with bogus error message about an
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/lib/libpbmfont.c b/lib/libpbmfont.c
index 2e6e66c1..4ba812cd 100644
--- a/lib/libpbmfont.c
+++ b/lib/libpbmfont.c
@@ -1297,6 +1297,8 @@ validateEncoding(const char **  const arg,
     bool badCodepoint;
     unsigned int codepoint;
 
+    if (!arg[1])
+        pm_error("Invalid ENCODING statement - no arguments");
     if (atoi(arg[1]) >= 0) {
         codepoint = atoi(arg[1]);
         gotCodepoint = true;
@@ -1327,10 +1329,14 @@ processCharsLine(FILE *        const fp,
                  const char ** const arg,
                  struct font * const fontP) {
 
-    unsigned int const nCharacters = atoi(arg[1]);
-
+    unsigned int nCharacters;
     unsigned int nCharsDone;
 
+    if (!arg[1])
+        pm_error("Invalid CHARS line - no arguments");
+
+    nCharacters = atoi(arg[1]);
+
     nCharsDone = 0;
 
     while (nCharsDone < nCharacters) {
@@ -1346,6 +1352,8 @@ processCharsLine(FILE *        const fp,
             /* ignore */
         } else if (!streq(arg[0], "STARTCHAR"))
             pm_error("no STARTCHAR after CHARS in BDF font file");
+        else if (!arg[1])
+            pm_error("Invalid STARTCHAR - no arguments");
         else {
             const char * const charName = arg[1];
             struct glyph * glyphP;
@@ -1377,15 +1385,25 @@ processCharsLine(FILE *        const fp,
                     const char * arg[32];
                     
                     expect(fp, "DWIDTH", arg, line);
+                    if (!arg[1])
+                        pm_error("Invalid DWIDTH statement - no arguments");
                     glyphP->xadd = atoi(arg[1]);
                 }
                 {
                     const char * arg[32];
                     
                     expect(fp, "BBX", arg, line);
+                    if (!arg[1])
+                        pm_error("Invalid BBX statement - no arguments");
                     glyphP->width  = atoi(arg[1]);
+                    if (!arg[2])
+                        pm_error("Invalid BBX statement - only 1 argument");
                     glyphP->height = atoi(arg[2]);
+                    if (!arg[3])
+                        pm_error("Invalid BBX statement - only 2 arguments");
                     glyphP->x      = atoi(arg[3]);
+                    if (!arg[4])
+                        pm_error("Invalid BBX statement - only 3 arguments");
                     glyphP->y      = atoi(arg[4]);
                 }
                 createBmap(glyphP->width, glyphP->height, fp, charName,
@@ -1420,8 +1438,13 @@ processFontLine(FILE *        const fp,
     } else if (streq(arg[0], "SIZE")) {
         /* ignore */
     } else if (streq(arg[0], "STARTPROPERTIES")) {
-        unsigned int const propCount = atoi(arg[1]);
+        unsigned int propCount;
         unsigned int i;
+
+        if (!arg[1])
+            pm_error("Invalid STARTPROPERTIES statement - no arguments");
+        propCount = atoi(arg[1]);
+
         for (i = 0; i < propCount; ++i) {
             char line[1024];
             const char * arg[32];
@@ -1431,9 +1454,17 @@ processFontLine(FILE *        const fp,
                 pm_error("End of file after STARTPROPERTIES in BDF font file");
         }
     } else if (streq(arg[0], "FONTBOUNDINGBOX")) {
+        if (!arg[1])
+            pm_error("Invalid FONTBOUNDINGBOX  statement - no arguments");
         fontP->maxwidth  = atoi(arg[1]);
+        if (!arg[2])
+            pm_error("Invalid FONTBOUNDINGBOX  statement - only 1 argument");
         fontP->maxheight = atoi(arg[2]);
+        if (!arg[3])
+            pm_error("Invalid FONTBOUNDINGBOX  statement - only 2 arguments");
         fontP->x         = atoi(arg[3]);
+        if (!arg[4])
+            pm_error("Invalid FONTBOUNDINGBOX  statement - only 3 arguments");
         fontP->y         = atoi(arg[4]);
     } else if (streq(arg[0], "ENDFONT")) {
         *endOfFontP = true;
diff --git a/version.mk b/version.mk
index 2173a243..797019a9 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 47
-NETPBM_POINT_RELEASE = 69
+NETPBM_POINT_RELEASE = 70