From d4e51f7ac9a6b506136ce1747244783977f47ea2 Mon Sep 17 00:00:00 2001 From: ManasBagul23 Date: Wed, 18 Nov 2026 18:01:54 +0530 Subject: [PATCH] pdftops: reject a negative pdftops-max-image-resolution The "pdftops-max-image-resolution" job option is parsed with sscanf("%d") and stored into maxres without a range check. The image rendering resolution is then reduced with if (maxres) while (res > maxres) res = res / 2; For a negative value, res halves down to 0 and then stays there, and 0 > maxres is still true, so the loop never terminates: a job submitted with e.g. -o pdftops-max-image-resolution=-1 hangs ppdFilterPDFToPS() at 100% CPU before the renderer is ever started. Only accept non-negative values; anything else falls through to the existing "Invalid value" warning and keeps the default ceiling. --- ppd/pdftops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppd/pdftops.c b/ppd/pdftops.c index d1ad2efd..0bb31c53 100644 --- a/ppd/pdftops.c +++ b/ppd/pdftops.c @@ -1020,7 +1020,7 @@ ppdFilterPDFToPS(int inputfd, // I - File descriptor input stream if ((val = cupsGetOption("pdftops-max-image-resolution", num_options, options)) != NULL) { - if ((numvalues = sscanf(val, "%d", &mres)) > 0) + if ((numvalues = sscanf(val, "%d", &mres)) > 0 && mres >= 0) maxres = mres; else if (log) log(ld, CF_LOGLEVEL_WARN,