Skip to content

parser common BUGFIX revision-date of import/include in ext instances - #2624

Open
aravindor wants to merge 1 commit into
CESNET:develfrom
aravindor:fix-generic-revision-date
Open

aravindor wants to merge 1 commit into
CESNET:develfrom
aravindor:fix-generic-revision-date

Conversation

@aravindor

Copy link
Copy Markdown

lysp_stmt_import() and lysp_stmt_include() (reached when an extension instance contains import / include) parse revision-date from the parent stmt instead of the child, so it always fails with an Invalid keyword "prefix" as a child of "import" error. They also strcpy() the value into the 11-byte rev[] before lys_check_date() checks its length, so correcting only the statement would overflow rev[] with a longer value.

This adds lysp_stmt_revision_date(), mirroring parse_revisiondate() in the YANG parser: duplicate check, validate, then copy. It also passes revision-date (not the import / include) as the parent statement of its extension instances.

Verified on devel with -fsanitize=address,undefined using a small extension plugin that permits import as a substatement:

  • current devel: the import's revision-date always fails (dead path);
  • with only stmt → child: a long revision-date is an out-of-bounds write caught by ASan in strcpy at parser_common.c;
  • with this change: a valid date is accepted, an over-long one is rejected with Invalid length ... of a revision-date and 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.

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.
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