Repository navigation
Filter printer strings in generated PPD labels and validate keyword/finishing attributes - #129
Merged
Merged
Conversation
ppdCreatePPDFromIPP2() takes option and choice labels from the printer's strings file (printer-strings-uri) and wrote most of them into the PPD with a bare "%s": the *OpenUI labels of InputSlot, MediaType, ColorModel, Duplex, OutputBin, the finishing options, cupsPrintQuality, print-content-optimize, cupsRenderingIntent, print-scaling and the fax options, and the choice labels of PageSize, PageRegion, InputSlot, ColorModel, Duplex, cupsPrintQuality and the rest. cfCatalogLoad() turns "\n", "\r" and "\NNN" in that file into the characters themselves, so a label with a line break ended the PPD line and the rest of the label became a new PPD keyword. A ":" ended a label early, and a long label made a line too long for ppdOpen(), which then failed to load the PPD. Write every label through a new ppd_label(), which cuts the text at the first control character, escapes ":" and "<" as hex (as ppd_put_string() did), and cuts it to PPD_MAX_TEXT bytes without splitting an escape or a UTF-8 character; a PageSize label leaves room for " (Borderless)". ppd_put_string() uses it too, which also brings over the CUPS fix for control characters in localization strings (CUPS commit 989cfca1). The localizations of the cupsFinishingTemplate and APPrinterPreset choices were written inside the quoted values of those keywords, so they were never loaded as localizations. Write them after the value, as CUPS does. Add tests for labels from a printer strings file to test_ppd_generator. Addresses GHSA-4frw-3m3q-mwfx.
Two more places in ppdCreatePPDFromIPP2() wrote values from the printer into the PPD without checking them: - print-content-optimize-supported, print-rendering-intent-supported and print-scaling-supported were looked up with any value tag, so a text value, which may hold a line break, became a choice keyword, and their -default values were not validated; - the member names of finishings-col-database entries were written into the quoted *cupsFinishingTemplate value. Look up the -supported values as keywords and check them and the -default values with ippValidateAttribute(), and skip finishing members that do not validate. (Preset members in job-presets-supported are already checked since 6b13207.) Add tests for these values to test_ppd_generator. Addresses GHSA-4frw-3m3q-mwfx.
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 commits addressing
GHSA-4frw-3m3q-mwfx, rebased onto currentmaster(02b76e2f):ppd/ppd-generator.c,ppd/test_ppd_generator.c): route all option and choice labels fromprinter-strings-urithrough a newppd_label()helper (stopping at control characters, hex-escaping:and<, and truncating cleanly toPPD_MAX_TEXTwithout splitting escapes or UTF-8), reuse it inppd_put_string()(bringing over CUPS989cfca1), and emitcupsFinishingTemplateandAPPrinterPresetlocalizations after their quoted values. Adds Group 14 (T51–T57) totest_ppd_generator.ppd/ppd-generator.c,ppd/test_ppd_generator.c): look upprint-content-optimize-supported,print-rendering-intent-supported, andprint-scaling-supportedas keywords and validate them, their-defaultvalues, andfinishings-col-databasemember attributes withippValidateAttribute(). (Preset members injob-presets-supportedare already validated since6b132075.) Adds Group 15 (T58–T60) totest_ppd_generator.Verified in both plain and AddressSanitizer+UndefinedBehaviorSanitizer builds: all 64
test_ppd_generatorchecks pass, and the rest ofmake checkmatchesmaster.Please preserve commit authorship when merging (e.g., rebase and merge) so both commits and their tests stay intact.