Repository navigation
plugins types BUGFIX read past short date values - #2637
Merged
Merged
Conversation
lyplg_type_store_date() builds a date-and-time string from the first 10 characters of the value and the rest after them, relying on the pattern to guarantee a full date. With LYPLG_TYPE_STORE_ONLY the pattern is skipped, so for a shorter value the precision of the second %.*s is negative and asprintf() reads from value + 10, past the end of the value, until a NUL byte. An escaped value such as &CESNET#50; is passed in an exact-size heap buffer, and a value pointing into the input is parsed together with the following markup, so <l2>2</l2> followed by another element was accepted as a date.
michalvasko
approved these changes
Nov 18, 2026
Member
|
Thanks, such invalid memory access needs to be avoided but also the |
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.
Repro: with
l2ayang:dateleaf, parsing<l2 xmlns="urn:tests:a">2</l2><l2nz xmlns="urn:tests:a">2005-05-31</l2nz>withLYD_PARSE_STORE_ONLYsucceeds, the "date" being parsed out of the markup of the next element. with2instead of2the value sits in an exact-size heap buffer and the read runs past it, andlyd_new_term()withLYD_NEW_VAL_STORE_ONLYon a"2"placed right before a no-access page dies with an access violation.Cause:
lyplg_type_store_date()builds the date-and-time string with"%.*sT00:00:00%.*s", 10, value, value_size - 10, value + 10, which only works if the pattern already guaranteed a full date. store-only skips the pattern, so for a shorter value the second precision is negative, printf ignores it and%sreads fromvalue + 10until it hits a NUL.Fix: reject values shorter than a date before building the string, with the same "Failed to parse" error the date-no-zone branch uses. the new cases in
test_data_xmlfail on the current tree and pass with the fix.