From 34bb24c566c9d9fe3c4ae71fc4c6b53323fb1dd9 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 22 Mar 2020 17:59:06 +0000 Subject: Release 10.89.03 git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3771 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/other/pbmtopgm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'converter/other/pbmtopgm.c') 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 +#include #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]); -- cgit 1.4.1