Skip to content

parser xml BUGFIX envelope freed on error before being set - #2589

Open
mardgez13 wants to merge 1 commit into
CESNET:develfrom
mardgez13:fix-netconf-envelope
Open

mardgez13 wants to merge 1 commit into
CESNET:develfrom
mardgez13:fix-netconf-envelope

Conversation

@mardgez13

Copy link
Copy Markdown

lydxml_envelope() frees *envp in 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) *envp has not been assigned yet. lydxml_env_netconf_rpc() passes its local child for the optional action envelope without initializing it, so a NETCONF <rpc> whose <action> element carries a text value makes lyd_parse_op() call lyd_free_tree() on an uninitialized pointer instead of returning LY_EVALID.

Fix: lydxml_envelope() creates the node into a local variable, assigns *envp only on success and frees only that local on error, so callers never get an unassigned pointer freed for them. child in lydxml_env_netconf_rpc() is initialized as in lydxml_env_netconf_reply().

Test: test_netconf_action in tests/utests/data/test_parser_xml.c now checks that such an RPC is rejected with LY_EVALID, the expected error message and NULL tree/op. The whole test suite passes with ASan/UBSan.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant