Skip to content

ppd-cache.c: Guard against empty options in ppdCacheAssignPresets() - #110

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
RonitMehta08:fix/ppd-cache-empty-option-81
Nov 14, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
RonitMehta08:fix/ppd-cache-empty-option-81

Conversation

@RonitMehta08

Copy link
Copy Markdown
Contributor

Summary

In ppdCacheAssignPresets() (ppd/ppd-cache.c), the Foomatic composite-option check accesses option->choices[0].choice without verifying that option->num_choices > 0 and option->choices != NULL. A Foomatic PPD containing an empty *OpenUI / *CloseUI block triggers a near-NULL read (SEGV) in strncmp().

Changes

  • Skip options with option->num_choices <= 0 || !option->choices in ppdCacheAssignPresets() and guard option->choices[0].choice with option->num_choices > 0 && option->choices.
  • Add regression test T53 in ppd/test_ppd_cache.c verifying that ppdCacheCreateWithPPD() succeeds on a Foomatic PPD containing an empty *OpenUI option under AddressSanitizer / UndefinedBehaviorSanitizer.

Fixes #81

In ppdCacheAssignPresets(), skip options with option->num_choices <= 0 or a NULL choices array before inspecting option->choices[0].choice in the Foomatic composite-option check. Previously, a Foomatic PPD containing an empty *OpenUI/*CloseUI block triggered a near-NULL read in strncmp().

Add regression test T53 in ppd/test_ppd_cache.c verifying ppdCacheCreateWithPPD() succeeds on a Foomatic PPD with an empty OpenUI option.

Fixes OpenPrinting#81

Signed-off-by: Ronit Mehta <ronitdmehta@gmail.com>
@tillkamppeter
tillkamppeter merged commit 8eba994 into OpenPrinting:master Nov 14, 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.

libppd: an empty Foomatic option dereferences choices[0]

2 participants