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/libpam.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/libpam.c')
-rw-r--r-- | lib/libpam.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/libpam.c b/lib/libpam.c index 07241e9e..206e850f 100644 --- a/lib/libpam.c +++ b/lib/libpam.c @@ -132,19 +132,7 @@ validateComputableMaxval(const struct pam * const pamP) { /*---------------------------------------------------------------------------- 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 (pamP->maxval == 0) - pm_error("Maxval is zero. Must be at least one."); - - if (pamP->maxval > INT_MAX-1) - pm_error("Maxval (%lu) is too large to be processed", pamP->maxval); + pgm_validateComputableMaxval(pamP->maxval); } @@ -1121,6 +1109,8 @@ pnm_writepaminit(struct pam * const pamP) { switch (PAM_FORMAT_TYPE(pamP->format)) { case PAM_TYPE: + validateComputableSize(pamP); + validateComputableMaxval(pamP); /* See explanation below of why we ignore 'pm_plain_output' here. */ fprintf(pamP->file, "P7\n"); writeComments(pamP); |