Repository navigation
ppd-cache: fix inverted PWG-to-PPD comparisons for source and type - #112
Merged
tillkamppeter merged 1 commit intoNov 17, 2026
Conversation
ppdPwgInputSlotForSource() and ppdPwgMediaTypeForType() ran their whole if/else-if chain on the raw, un-negated result of _ppd_strcasecmp(), which returns 0 for a match (standard strcasecmp semantics) - the opposite of what a truthy if-condition needs. Every other comparison in this file already negates it (!_ppd_strcasecmp(...)); these two functions were the only ones that didn't, so they picked the PPD InputSlot/MediaType name for the wrong PWG keyword in almost every case, e.g. media-source "main" got mapped to "Multipurpose" instead of "Cassette". Negate the comparisons like everywhere else.
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.
Summary
`ppdPwgInputSlotForSource()` and `ppdPwgMediaTypeForType()` run their whole if/else-if chain on the raw, un-negated result of `_ppd_strcasecmp()`.
The bug
`_ppd_strcasecmp()` follows standard `strcasecmp` semantics: it returns `0` when the strings match. An unnegated `if (_ppd_strcasecmp(media_source, "main"))` is therefore true precisely when `media_source` is not `"main"` -- the opposite of what the if/else-if chain needs. Every other `_ppd_strcasecmp()` call in this file is already negated (`!_ppd_strcasecmp(...)`) or used in a context that actually wants "not equal" (e.g. `cupsCommands != "none"`); these two functions were the only ones using the raw result for an equality branch.
In practice this means both functions pick the PPD InputSlot/MediaType name for essentially the wrong PWG keyword: e.g. media-source `"main"` maps to `"Multipurpose"` instead of `"Cassette"`, media-type `"stationery"` maps to `"Cardstock"` instead of `"Plain"`, and so on down each chain.
Fix
Negate the comparisons, matching the pattern used everywhere else in this file.
Test plan