Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser hangs on stream of %Y #638

Closed
ingydotnet opened this issue Oct 2, 2021 · 4 comments
Closed

Parser hangs on stream of %Y #638

ingydotnet opened this issue Oct 2, 2021 · 4 comments

Comments

@ingydotnet
Copy link

ingydotnet commented Oct 2, 2021

Found this bug while trying things in https://spec.yaml.io/main/playground/parser.

It froze the entire page because of it. I'll need to add a timeout certainly but thought you should know.

To Reproduce

docker run --rm -it yamlio/yaml-editor bash -c 'echo -n "%Y" | /yaml/bin/dotnet-yamldotnet-event'
dmitry-ra added a commit to dmitry-ra/YamlDotNet that referenced this issue Dec 31, 2021
@dmitry-ra
Copy link
Contributor

Bug was planted in commit 08c929f when reserved directive support was added.

This while loop is endless - analyzer uses buffer, that don't care about overflows and ranges.

while (!analyzer.Check('#') && !analyzer.IsBreak())
{
    Skip();
}

@ingydotnet
Copy link
Author

ingydotnet commented Dec 31, 2021

You can see it here: https://play.yaml.io/main/parser?input=JVk=

Playing around in there it seems to hang on any directive line (including reserved) that does not have a line break.

See https://play.yaml.io/main/parser?input=I3h4eApmb286IGJhcgouLi4KJXh5eiBAJCVeJio=

I added a TIMEOUT message when the parser takes more then 1 second to complete.

@ingydotnet
Copy link
Author

Related, directives must be follow by a --- line or the parser should error.

See https://play.yaml.io/main/parser?input=JVhZWgo=
vs https://play.yaml.io/main/parser?input=JVhZWgotLS0K

dmitry-ra added a commit to dmitry-ra/YamlDotNet that referenced this issue Jul 13, 2022
@aaubry
Copy link
Owner

aaubry commented Jul 23, 2022

A fix for this issue has been released in version 12.0.0.

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

No branches or pull requests

3 participants