Repository navigation
Limit nested IPP data-file collection parsing - #222
Open
ManasBagul23 wants to merge 2 commits into
Open
ManasBagul23 wants to merge 2 commits into
ManasBagul23 wants to merge 2 commits into
Conversation
ippFileReadCollection() and parse_value() call each other recursively
once per nested collection value ("{ ... }" inside an ATTR/MEMBER), with
no limit on how deep that nesting can go. A data/test file with enough
nested collection values drives this straight into a stack overflow
instead of a parse error. Track the current nesting depth on the file
object and refuse to go past a reasonable limit.
michaelrsweet
left a comment
Member
There was a problem hiding this comment.
I think the max depth should be common between the IPP message parser (max depth 10) and IPP files...
Contributor
Author
|
Agreed. I moved the limit into the shared private header and now use it in both the IPP message parser and IPP data-file collection parser, keeping the maximum depth at 10. |
michaelrsweet
requested changes
Nov 19, 2026
michaelrsweet
left a comment
Member
There was a problem hiding this comment.
I'm liking the changes, just need a little cleanup (see comments) and we should be good. Thanks!
| // | ||
|
|
||
| # define _CUPS_MAX_OPTION_DEPTH 4 // Maximum depth of nested options/collections | ||
| # define _IPP_MAX_DEPTH 10 // Maximum depth of nested IPP collections |
Member
There was a problem hiding this comment.
This should be in ipp-private.h...
| void *cb_data; // Callback data | ||
| char *buffer; // Output buffer | ||
| size_t alloc_buffer; // Size of output buffer | ||
| size_t collection_depth; |
Member
There was a problem hiding this comment.
This can just be an int...
| }; | ||
|
|
||
|
|
||
| // |
Member
There was a problem hiding this comment.
and probably remove this comment block... :)
This branch has not been deployed
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.
ippFileReadCollection and parse_value recurse for each nested collection without a depth limit. A deeply nested IPP data file can exhaust the process stack. Track collection nesting on the file object and reject input once it exceeds a fixed maximum depth.