Repository navigation
pdftops: fix the printer make and model used for quirks - #97
Merged
Merged
Conversation
For a printer-make-and-model starting with "Hewlett-Packard " or "Hewlett Packard ", strncpy(make, "HP", sizeof(make)) pads the rest of the buffer with NULs, which wipes the model it was about to use. "Hewlett-Packard LaserJet 4000" came out as "HP ", so the HP LaserJet quirks never matched. Write just "HP" and its terminator instead. In the PPD case, ppd->product is only set if the PPD has a *Product line, so without one ppd->product + 1 crashes, and an empty *Product reads past the end of the string. Leave the make and model empty in those cases, the code after it already handles that.
Ar-maan05
force-pushed
the
pdftops-make-model
branch
from
November 2, 2026 03:42
751c38f to
2190529
Compare
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.
two small bugs in how
ppdFilterPDFToPS()works out the make and model it uses for printer quirks.before/after from a small harness calling the filter:
the first one is
strncpy(make, "HP", sizeof(make))padding the whole buffer with NULs, which also clears the model becuasemodelpoints into that same buffer. So those printers never matched the HP LaserJet checks further down. The other two come from usingppd->product + 1without checking it's there.the fix writes only the 3 bytes of "HP" and skips the PPD branch when there's no usable manufacturer or product. An empty make and model is already handled by the code below.
tested with ASan and UBSan using that harness. I didn't add a repo test since the filter goes on to run a renderer, happy to add one if you have a preference for how.