Repository navigation
parser cbor BUGFIX metadata coupled with the wrong node - #2632
Merged
Merged
Conversation
lydcbor_subtree_r() processes all the members of a map in one call, but attr_node, set for a "@" member, was not reset for the following members, so any later "@name" metadata were coupled with the parent instead of the named sibling. With an opaque parent, and also for opaque leaf-list instances, the leaf-list error path then dereferenced the NULL schema of the previous instance.
michalvasko
approved these changes
Nov 16, 2026
Member
|
Thanks, merging. |
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.
lydcbor_subtree_r()walks every member of a CBOR map in one loop, unlikelydjson_subtree_r()which is called once per member, soattr_nodeset for a"@"member (the parent's own metadata) is never cleared and every later"@name"member in that map gets coupled with the parent instead of the named sibling. libyang's own output shows it:{"cbor-test:cont-root":{"@":{"cbor-test:a1":"val1"},"lf-root-str":"x","@lf-root-str":{"cbor-test:a2":5}}}printed as CBOR and parsed back ends up witha2oncont-root, and leaf-list metadata in a list entry that has its own"@"is rejected with "Missing CBOR data instance #2". when the parent is opaque, which is always the case for anydata content parsed with default options, a following"@mod:leaf-list"array walks past the parent and the error path inlydcbor_meta_attr()readsprev->schema->moduleof an opaque node, so a small untrusted CBOR document crashes the parser (NULL read, ASan SEGV). the same read is reachable without the stale pointer from an opaque leaf-list instance, e.g.{"cbor-test:ll-intg32":["x"],"@cbor-test:ll-intg32":[null,null]}withLYD_PARSE_OPAQ. it showed up while comparing the CBOR member loop with the JSON one. the fix clearsattr_nodeper member and builds the message fromsnode, which is what picks the leaf-list branch there;test_attributes_parentintest_cbor.ccovers all three cases and fails without the change.