From 731c59b6e76abe8c872993ecb845f8c23599188a Mon Sep 17 00:00:00 2001 From: giraffedata Date: Wed, 20 Sep 2023 02:12:59 +0000 Subject: Fix arithmetic overlow git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4670 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/pbm/ybmtopbm.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'converter/pbm') diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c index 36f2dee7..78eb79f2 100644 --- a/converter/pbm/ybmtopbm.c +++ b/converter/pbm/ybmtopbm.c @@ -10,6 +10,8 @@ ** implied warranty. */ +#include + #include "pm.h" #include "pbm.h" #include "bitreverse.h" @@ -80,6 +82,9 @@ main(int argc, const char * argv[]) { getinit(ifP, &cols, &rows, &depth); if (depth != 1) pm_error("YBM file has depth of %u, must be 1", (unsigned int) depth); + if (cols > INT_MAX - 15) + pm_error("YBM file has uncomputably large width %d", cols); + pbm_writepbminit(stdout, cols, rows, 0); -- cgit 1.4.1