about summary refs log tree commit diff
path: root/lib/libpbm2.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-09-29 17:52:10 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-09-29 17:52:10 +0000
commitbf85274a5c089c1c6295f0caf54ecf0c1c42e887 (patch)
tree54564e27e71bb7e6f85a6bf121d47df731c04f99 /lib/libpbm2.c
parentc8ea970312eb3e9877d876e5b4d5575237187197 (diff)
downloadnetpbm-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/libpbm2.c')
-rw-r--r--lib/libpbm2.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/lib/libpbm2.c b/lib/libpbm2.c
index 244d5835..c71193c9 100644
--- a/lib/libpbm2.c
+++ b/lib/libpbm2.c
@@ -58,28 +58,6 @@ pbm_readpbminitrest( FILE * const file,
 
 
 
-static void
-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
-   overflows.  Note that in C, arithmetic is always modulus
-   arithmetic, so if your values are too big, the result is not what
-   you expect.  That failed expectation can be disastrous if you use
-   it to allocate memory.
-
-   See comments at 'validateComputableSize' in libpam.c for details on
-   the purpose of these validations.
------------------------------------------------------------------------------*/
-    if (cols > INT_MAX - 10)
-        pm_error("image width (%u) too large to be processed", cols);
-    if (rows > INT_MAX - 10)
-        pm_error("image height (%u) too large to be processed", rows);
-}
-
-
-
 void
 pbm_readpbminit(FILE * const ifP,
                 int *  const colsP,
@@ -115,7 +93,7 @@ pbm_readpbminit(FILE * const ifP,
         pm_error("bad magic number 0x%x - not a PPM, PGM, PBM, or PAM file",
                  realFormat);
     }
-    validateComputableSize(*colsP, *rowsP);
+    pbm_validateComputableSize(*colsP, *rowsP);
 }