Fix index out of bounds when parsing GFM footnote#667
Merged
Martin1887 merged 1 commit intopulldown-cmark:masterfrom Jun 18, 2023
Merged
Fix index out of bounds when parsing GFM footnote#667Martin1887 merged 1 commit intopulldown-cmark:masterfrom
Martin1887 merged 1 commit intopulldown-cmark:masterfrom
Conversation
The code here was introduced in pulldown-cmark#654 and the crash was found using cargo fuzz run parse Fixes pulldown-cmark#666.
Collaborator
|
Looks fine to me 👍 |
notriddle
reviewed
Jun 17, 2023
| || (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':'))) |
Collaborator
There was a problem hiding this comment.
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)).
Collaborator
Author
There was a problem hiding this comment.
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.
notriddle
approved these changes
Jun 18, 2023
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.
The code here was introduced in #654 and the crash was found using
Fixes #666.