Skip to content

Filter printer strings in generated PPD labels and validate keyword/finishing attributes - #129

Merged
tillkamppeter merged 2 commits into
OpenPrinting:masterfrom
alepacheco:catalog-labels
Dec 1, 2026
Merged

tillkamppeter merged 2 commits into
OpenPrinting:masterfrom
alepacheco:catalog-labels

Conversation

@alepacheco

Copy link
Copy Markdown
Contributor

Two commits addressing GHSA-4frw-3m3q-mwfx, rebased onto current master (02b76e2f):

  1. Filter printer strings in the labels of generated PPDs (ppd/ppd-generator.c, ppd/test_ppd_generator.c): route all option and choice labels from printer-strings-uri through a new ppd_label() helper (stopping at control characters, hex-escaping : and <, and truncating cleanly to PPD_MAX_TEXT without splitting escapes or UTF-8), reuse it in ppd_put_string() (bringing over CUPS 989cfca1), and emit cupsFinishingTemplate and APPrinterPreset localizations after their quoted values. Adds Group 14 (T51–T57) to test_ppd_generator.
  2. Only write validated printer values into generated PPDs (ppd/ppd-generator.c, ppd/test_ppd_generator.c): look up print-content-optimize-supported, print-rendering-intent-supported, and print-scaling-supported as keywords and validate them, their -default values, and finishings-col-database member attributes with ippValidateAttribute(). (Preset members in job-presets-supported are already validated since 6b132075.) Adds Group 15 (T58–T60) to test_ppd_generator.

Verified in both plain and AddressSanitizer+UndefinedBehaviorSanitizer builds: all 64 test_ppd_generator checks pass, and the rest of make check matches master.

Please preserve commit authorship when merging (e.g., rebase and merge) so both commits and their tests stay intact.

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.
@tillkamppeter
tillkamppeter merged commit 80b3b25 into OpenPrinting:master Dec 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants