Skip to content

ppd-ipp.c: Prevent stack buffer overflow on >20-item PPD attributes - #108

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
RonitMehta08:fix/ppd-ipp-items-overflow-85
Nov 14, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
RonitMehta08:fix/ppd-ipp-items-overflow-85

Conversation

@RonitMehta08

@RonitMehta08 RonitMehta08 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In ppdLoadAttributes() (ppd/ppd-ipp.c), comma-separated raster PPD attributes (cupsUrfSupported, cupsPwgRaster*, cupsPclm*) are split into a fixed 20-element stack array (const char *items[20], along with res_x[20], res_y[20], and int_item[20]) without bounding num_items. A PPD attribute containing 21 or more comma-separated items writes past items[20] on the stack.

Changes

  • Bound the comma-splitting do ... while loop in ppdLoadAttributes() to num_items < (int)(sizeof(items) / sizeof(items[0])) (matching the existing margins and print-rendering-intent-supported bounds in ppdLoadAttributes()).
  • Guard against NULL ppd_attr->value before strncpy() and explicitly NUL-terminate buf[sizeof(buf) - 1] = '\0'.
  • Add regression test T70 in ppd/test_ppd_ipp.c verifying that a 21-item cupsPwgRasterAuditSupported attribute is safely capped at 20 items without stack buffer overflow under ASan/UBSan.

Fixes #85

In ppdLoadAttributes(), bound the comma-separated attribute splitting loop to the capacity of items[20] (sizeof(items) / sizeof(items[0])), guard against NULL ppd_attr->value, and explicitly null-terminate buf after strncpy(). Previously, a cupsUrfSupported, cupsPwgRaster*, or cupsPclm* attribute with more than 20 comma-separated values wrote past items[20] (and res_x[20]/res_y[20]/int_item[20]) on the stack.

Add regression test T70 in ppd/test_ppd_ipp.c verifying a 21-item cupsPwgRasterAuditSupported attribute is safely capped at 20 items.

Fixes OpenPrinting#85

Signed-off-by: Ronit Mehta <ronitdmehta@gmail.com>
@tillkamppeter
tillkamppeter merged commit b24c647 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: a 21-item PPD attribute writes past items[20]

2 participants