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/libppm1.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/libppm1.c')
-rw-r--r-- | lib/libppm1.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/lib/libppm1.c b/lib/libppm1.c index 427adf4d..9df1f213 100644 --- a/lib/libppm1.c +++ b/lib/libppm1.c @@ -88,9 +88,9 @@ ppm_readppminitrest(FILE * const fileP, -static void -validateComputableSize(unsigned int const cols, - unsigned int const rows) { +void +ppm_validateComputableSize(unsigned int const cols, + unsigned int const rows) { /*---------------------------------------------------------------------------- Validate that the dimensions of the image are such that it can be processed in typical ways on this machine without worrying about @@ -113,28 +113,6 @@ validateComputableSize(unsigned int const cols, -static void -validateComputableMaxval(pixval const maxval) { -/*---------------------------------------------------------------------------- - This is similar to validateComputableSize, but for the maxval. ------------------------------------------------------------------------------*/ - /* Code sometimes allocates an array indexed by sample values and - represents the size of that array as an INT. (UNSIGNED INT would be - more proper, but there's no need to be that permissive). - - Code also sometimes iterates through sample values and quits when the - value is greater than the maxval. - */ - - if (maxval == 0) - pm_error("Maxval is zero. Must be at least one."); - - if (maxval > INT_MAX-1) - pm_error("Maxval (%u) is too large to be processed", maxval); -} - - - void ppm_readppminit(FILE * const fileP, int * const colsP, @@ -172,9 +150,9 @@ ppm_readppminit(FILE * const fileP, pm_error("bad magic number 0x%x - not a PPM, PGM, PBM, or PAM file", realFormat); } - validateComputableSize(*colsP, *rowsP); + ppm_validateComputableSize(*colsP, *rowsP); - validateComputableMaxval(*maxvalP); + pgm_validateComputableMaxval(*maxvalP); } |