From d125f80dee009c1297cc63e4209f78c4524e7d9a Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 16 May 2021 15:47:08 +0200 Subject: [PATCH] WRaster: Stop parsing number in PPM file if invalid syntax is found When the function 'pm_getuint' is reading a number, it prints an error message if it encounters a non-digit number, yet it still enters the processing loop which will cause an invalid number to be calculated. Signed-off-by: Christophe CURIS --- wrlib/load_ppm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wrlib/load_ppm.c b/wrlib/load_ppm.c index 8d1ab72b..31bc4606 100644 --- a/wrlib/load_ppm.c +++ b/wrlib/load_ppm.c @@ -85,8 +85,10 @@ int pm_getuint(FILE * const ifP) ch = pm_getc(ifP); } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - if (ch < '0' || ch > '9') + if (ch < '0' || ch > '9') { fprintf(stderr, "junk in file where an unsigned integer should be\n"); + return -1; + } i = 0; do {