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

Fix index out of bounds when parsing GFM footnote #667

Merged
merged 1 commit into from Jun 18, 2023

Conversation

mgeisler
Copy link
Collaborator

The code here was introduced in #654 and the crash was found using

cargo fuzz run parse

Fixes #666.

The code here was introduced in pulldown-cmark#654 and the crash was found using

    cargo fuzz run parse

Fixes pulldown-cmark#666.
@notriddle
Copy link
Collaborator

Looks fine to me 👍

|| (gfm_footnote
&& bytes.starts_with(b"[^")
&& scan_link_label_rest(std::str::from_utf8(&bytes[2..]).unwrap(), &|_| None)
.map_or(false, |(len, _)| bytes.get(2 + len) == Some(&b':')))
Copy link
Collaborator

@notriddle notriddle Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like most of this is just reformatting, except for the last line that makes it handle the case where scan_link_label_rest scans the entire file and points it at the end (replacing bytes[2 + len] with bytes.get(2 + len)).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like most of this is just reformatting, except for the last line

Yes, that's correct! I have my editor configured to run rustfmt automatically, so the entire file had lots of changes after my edit. I staged the relevant hunk and reverted the rest. I'm now to the project, so I don't really know the preferred style yet, but I figured the long chain of && was easier to read this way.

@Martin1887 Martin1887 merged commit 759fc2c into pulldown-cmark:master Jun 18, 2023
1 check failed
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.

Index out of bounds at firstpass.rs:1424
3 participants