diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-09-29 17:52:10 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-09-29 17:52:10 +0000 |
commit | bf85274a5c089c1c6295f0caf54ecf0c1c42e887 (patch) | |
tree | 54564e27e71bb7e6f85a6bf121d47df731c04f99 /lib/libpgm2.c | |
parent | c8ea970312eb3e9877d876e5b4d5575237187197 (diff) | |
download | netpbm-mirror-bf85274a5c089c1c6295f0caf54ecf0c1c42e887.tar.gz netpbm-mirror-bf85274a5c089c1c6295f0caf54ecf0c1c42e887.tar.xz netpbm-mirror-bf85274a5c089c1c6295f0caf54ecf0c1c42e887.zip |
Validate computable image size and maxval in libnetpbm write init functions
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4706 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpgm2.c')
-rw-r--r-- | lib/libpgm2.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libpgm2.c b/lib/libpgm2.c index 2e3aba90..ec3539a2 100644 --- a/lib/libpgm2.c +++ b/lib/libpgm2.c @@ -15,6 +15,7 @@ #include "netpbm/pm_c_util.h" #include "netpbm/mallocvar.h" +#include "libpgm.h" #include "pgm.h" @@ -28,6 +29,13 @@ pgm_writepgminit(FILE * const fileP, bool const plainFormat = forceplain || pm_plain_output; + /* For Caller's convenience, we include validating computability of the + image parameters, since Caller may be using them in arithmetic after + our return. + */ + pgm_validateComputableSize(cols, rows); + pgm_validateComputableMaxval(maxval); + if (maxval > PGM_OVERALLMAXVAL && !plainFormat) pm_error("too-large maxval passed to ppm_writepgminit(): %d.\n" "Maximum allowed by the PGM format is %d.", |