From 3f183168c393a7d67ff8afc751496aa3079bf3e5 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 5 Aug 2023 23:07:45 +0000 Subject: 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 --- other/pamstack.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'other') 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; } -- cgit 1.4.1