Skip to content

parser lyb BUGFIX reject a child hash without a schema parent - #2662

Open
Mohil-Ahuja wants to merge 1 commit into
CESNET:develfrom
Mohil-Ahuja:lyb-hash-without-parent
Open

Mohil-Ahuja wants to merge 1 commit into
CESNET:develfrom
Mohil-Ahuja:lyb-hash-without-parent

Conversation

@Mohil-Ahuja

Copy link
Copy Markdown

A child node read at the top level, or as a child of an opaque node, has neither a schema parent nor a module. lyb_parse_schema_hash() then finds no match, and the error message dereferences the NULL schema parent. An assert() covers this in debug builds, but a release build crashes on the 4 bytes 02 fb 02 fb:

libyang[0]: Invalid argument last || parent || module (lys_getnext()).
Segmentation fault

The fix fails with "Invalid LYB data, schema node hash without a schema parent." before the lookup. It also turns the assert((*name)[0]) in lyb_parse_module() into an error, so 12 00 03 (an empty module name) no longer aborts a debug build.

Both inputs are in a new test_invalid_hash_parent in test_lyb.c. I found them by fuzzing lyd_parse_lyb on devel.

A child node read at the top level, or as a child of an opaque node,
has neither a schema parent nor a module. Its hash then never matches,
and the error message dereferenced the NULL schema parent, which an
assert hid only in debug builds. Fail with an error before the lookup
instead. Also reject an empty module name, which was only asserted.
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