From beea3bd8dd05a731fddfa447ff0bad19fe32c973 Mon Sep 17 00:00:00 2001 From: Peter Szabo Date: Tue, 27 Feb 2018 15:19:31 +0100 Subject: [PATCH] bugfix: fixed + 7 integer overflow in pnm_load_rawpbm; this fixes https://github.com/pts/sam2p/issues/22 --- input-pnm.ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input-pnm.ci b/input-pnm.ci index 6f7fff4..fffe4d5 100644 --- a/input-pnm.ci +++ b/input-pnm.ci @@ -392,7 +392,7 @@ pnm_load_rawpbm (PNMScanner *scan, fd = pnmscanner_fd(scan); /****pts****/ /* rowlen = (unsigned int)ceil((double)(info->xres)/8.0);*/ - rowlen=(info->xres+7)>>3; + rowlen = (info->xres >> 3) + (info->xres & 3 ? 1 : 0); /* buf = (unsigned char *)malloc(rowlen*sizeof(unsigned char)); */ XMALLOCT(buf, unsigned char*, rowlen*sizeof(unsigned char));