Repository navigation
pdftops: reject a negative pdftops-max-image-resolution - #121
Merged
tillkamppeter merged 1 commit intoNov 22, 2026
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
pdftops-max-image-resolutionjob option is parsed withsscanf("%d")and stored intomres/maxreswithout any range check. The resolution ceiling is then applied with:For a negative
maxres,reshalves down to 0 (integer division) and stays there, and0 > maxresremains true forever sincemaxresis negative — the loop never terminates. A job submitted with e.g.-o pdftops-max-image-resolution=-1hangsppdFilterPDFToPS()at 100% CPU before the renderer is even started.Only accept non-negative values from
sscanf; a negative or unparsable value now falls through to the existing "Invalid value" warning and keeps the default ceiling, matching how every other invalid input to this option is already handled.