Repository navigation
Conversation
lydxml_envelope() freed the caller's *envp on its error paths even when it had not been assigned yet, and lydxml_env_netconf_rpc() passed an uninitialized local for the optional "action" envelope. Create the node into a local variable, assign *envp only on success and free only the local on error. Also initialize the local.
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.
lydxml_envelope()frees*envpin its cleanup whenever it fails, but on the paths that fail before the opaque node is created (e.g. an unexpected value in the element)*envphas not been assigned yet.lydxml_env_netconf_rpc()passes its localchildfor the optionalactionenvelope without initializing it, so a NETCONF<rpc>whose<action>element carries a text value makeslyd_parse_op()calllyd_free_tree()on an uninitialized pointer instead of returningLY_EVALID.Fix:
lydxml_envelope()creates the node into a local variable, assigns*envponly on success and frees only that local on error, so callers never get an unassigned pointer freed for them.childinlydxml_env_netconf_rpc()is initialized as inlydxml_env_netconf_reply().Test:
test_netconf_actionintests/utests/data/test_parser_xml.cnow checks that such an RPC is rejected withLY_EVALID, the expected error message and NULLtree/op. The whole test suite passes with ASan/UBSan.