about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-03-26 02:06:57 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-03-26 02:06:57 +0000
commit99d760c5aa3dac7cbde58d10c7b0a9213602d7ad (patch)
tree57764fe3668a003963f96da6352ec82f2b442888 /converter
parentb7cd16e68be723fdb25725de1d59763fc7272fae (diff)
downloadnetpbm-mirror-99d760c5aa3dac7cbde58d10c7b0a9213602d7ad.tar.gz
netpbm-mirror-99d760c5aa3dac7cbde58d10c7b0a9213602d7ad.tar.xz
netpbm-mirror-99d760c5aa3dac7cbde58d10c7b0a9213602d7ad.zip
Release 10.86.11
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@3775 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-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]);