about summary refs log tree commit diff
path: root/other
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-08-05 23:07:45 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-08-05 23:07:45 +0000
commit3f183168c393a7d67ff8afc751496aa3079bf3e5 (patch)
treeee49dd4f5afd4bd8a9030dfe9b12d55b00c1963a /other
parent24123421ac90801b89e9a11df77e3b27440b0e60 (diff)
downloadnetpbm-mirror-3f183168c393a7d67ff8afc751496aa3079bf3e5.tar.gz
netpbm-mirror-3f183168c393a7d67ff8afc751496aa3079bf3e5.tar.xz
netpbm-mirror-3f183168c393a7d67ff8afc751496aa3079bf3e5.zip
Fix arithmetic overflow on total number of planes
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4575 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'other')
-rw-r--r--other/pamstack.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/other/pamstack.c b/other/pamstack.c
index 285e02c0..533795ca 100644
--- a/other/pamstack.c
+++ b/other/pamstack.c
@@ -242,6 +242,11 @@ processOneImageInAllStreams(unsigned int       const nInput,
         maxvalLcm = pm_lcm(maxvalLcm + 1, inpam[inputSeq].maxval + 1, 1,
                            PAM_OVERALL_MAXVAL + 1) - 1;
 
+        if (inpam[inputSeq].depth > UINT_MAX - outputDepth)
+            pm_error("Total number of planes is too large to compute "
+                     "(at least %u plus %u)",
+                     outputDepth, inpam[inputSeq].depth);
+
         outputDepth += inpam[inputSeq].depth;
     }