Repository navigation
Conversation
lysp_stmt_import() and lysp_stmt_include(), used when an extension instance contains import/include, parsed revision-date from the parent statement instead of the child, so it always failed with an "invalid keyword" error. They also copied the value into the 11-byte rev[] before lys_check_date() checked its length, so correcting only the statement would overflow rev[] with a longer value. Add lysp_stmt_revision_date(), mirroring parse_revisiondate() in the YANG parser: duplicate check, validate, then copy. Pass revision-date (not the import/include) as the parent of its extension instances.
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.
lysp_stmt_import()andlysp_stmt_include()(reached when an extension instance containsimport/include) parserevision-datefrom the parentstmtinstead of thechild, so it always fails with anInvalid keyword "prefix" as a child of "import"error. They alsostrcpy()the value into the 11-byterev[]beforelys_check_date()checks its length, so correcting only the statement would overflowrev[]with a longer value.This adds
lysp_stmt_revision_date(), mirroringparse_revisiondate()in the YANG parser: duplicate check, validate, then copy. It also passesrevision-date(not theimport/include) as the parent statement of its extension instances.Verified on
develwith-fsanitize=address,undefinedusing a small extension plugin that permitsimportas a substatement:devel: the import'srevision-datealways fails (dead path);stmt→child: a longrevision-dateis an out-of-bounds write caught by ASan instrcpyatparser_common.c;Invalid length ... of a revision-dateand no memory error.No built-in extension plugin accepts
import/include, so this is not reachable in a normal build and there is no utest for it. I'm happy to add one with a small test plugin if you'd like it.