Repository navigation
Limit nested IPP data-file collection parsing - #222
ManasBagul23 wants to merge 3 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
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...
|
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
left a comment
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 |
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; |
There was a problem hiding this comment.
This can just be an int...
| }; | ||
|
|
||
|
|
||
| // |
There was a problem hiding this comment.
and probably remove this comment block... :)
Move _IPP_MAX_DEPTH into ipp-private.h (both ipp.c and ipp-file.c already pull it in transitively via cups-private.h, so no new include is needed), declare collection_depth as a plain int instead of size_t, and remove the now-empty "Limits..." comment block left behind in ipp-file.c.
|
Done - moved _IPP_MAX_DEPTH into ipp-private.h, changed collection_depth to a plain int, and removed the stray comment block. |
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.