diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-01-01 18:32:33 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-01-01 18:32:33 +0000 |
commit | fb276fe4aa654789592e334b6c9a175935af2528 (patch) | |
tree | de5010ffb3dedf5af4a235fd63b15c56c606399c /editor/pamstretch.c | |
parent | b00e994dafd51ac801fef82b470ba79acc44efd3 (diff) | |
download | netpbm-mirror-fb276fe4aa654789592e334b6c9a175935af2528.tar.gz netpbm-mirror-fb276fe4aa654789592e334b6c9a175935af2528.tar.xz netpbm-mirror-fb276fe4aa654789592e334b6c9a175935af2528.zip |
Check uncomputably large scale factor
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3475 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pamstretch.c')
-rw-r--r-- | editor/pamstretch.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/editor/pamstretch.c b/editor/pamstretch.c index 8980dd0b..04883c35 100644 --- a/editor/pamstretch.c +++ b/editor/pamstretch.c @@ -24,6 +24,7 @@ #include <string.h> #include <stdlib.h> #include <ctype.h> +#include <limits.h> #include "pm_c_util.h" #include "pam.h" @@ -389,9 +390,18 @@ main(int argc,char *argv[]) { } { unsigned int const dropped = cmdline.edge_mode == EDGE_DROP ? 1 : 0; - - outpam.width = (inpam.width - dropped) * cmdline.xscale; - outpam.height = (inpam.height - dropped) * cmdline.yscale; + double const width = (inpam.width - dropped) * cmdline.xscale; + double const height = (inpam.height - dropped) * cmdline.yscale; + + if (width > INT_MAX - 2) + pm_error("output image width (%f) too large for computations", + width); + if (height > INT_MAX - 2) + pm_error("output image height (%f) too large for computation", + height); + + outpam.width = width; + outpam.height = height; pnm_writepaminit(&outpam); } |