about summary refs log tree commit diff
path: root/converter/other/pbmtopgm.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-03-22 17:59:06 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-03-22 17:59:06 +0000
commit34bb24c566c9d9fe3c4ae71fc4c6b53323fb1dd9 (patch)
treec60be5a294b657fac9504c43487fcaa0cd99cc48 /converter/other/pbmtopgm.c
parentd566a34acc0a433487000bb3c1afae798858e43f (diff)
downloadnetpbm-mirror-34bb24c566c9d9fe3c4ae71fc4c6b53323fb1dd9.tar.gz
netpbm-mirror-34bb24c566c9d9fe3c4ae71fc4c6b53323fb1dd9.tar.xz
netpbm-mirror-34bb24c566c9d9fe3c4ae71fc4c6b53323fb1dd9.zip
Release 10.89.03
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3771 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/pbmtopgm.c')
-rw-r--r--converter/other/pbmtopgm.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c
index 69b20fb2..c35e1cbe 100644
--- a/converter/other/pbmtopgm.c
+++ b/converter/other/pbmtopgm.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <limits.h>
 
 #include "pm_c_util.h"
 #include "pgm.h"
@@ -29,8 +30,13 @@ main(int argc, char *argv[]) {
     height = atoi(argv[2]);
     if (width < 1 || height < 1)
         pm_error("width and height must be > 0");
+    if (width > INT_MAX / height)
+        /* prevent overflow of "value" below */
+        pm_error("sample area (%u columns %u rows) too large",
+                 width, height);
+
     left=width/2; right=width-left;
-    up=width/2; down=height-up;
+    up=height/2; down=height-up;
 
     if (argc == 4)
         ifd = pm_openr(argv[3]);