Repository navigation
ppd-ipp.c: Prevent stack buffer overflow on >20-item PPD attributes - #108
Merged
tillkamppeter merged 1 commit intoNov 14, 2026
Merged
tillkamppeter merged 1 commit into
tillkamppeter merged 1 commit into
Conversation
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>
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
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 withres_x[20],res_y[20], andint_item[20]) without boundingnum_items. A PPD attribute containing 21 or more comma-separated items writes pastitems[20]on the stack.Changes
do ... whileloop inppdLoadAttributes()tonum_items < (int)(sizeof(items) / sizeof(items[0]))(matching the existing margins andprint-rendering-intent-supportedbounds inppdLoadAttributes()).NULLppd_attr->valuebeforestrncpy()and explicitly NUL-terminatebuf[sizeof(buf) - 1] = '\0'.T70inppd/test_ppd_ipp.cverifying that a 21-itemcupsPwgRasterAuditSupportedattribute is safely capped at 20 items without stack buffer overflow under ASan/UBSan.Fixes #85