Repository navigation
Conversation
get_link_type() in src/latex.c compared the URL against the first
child's data and len without checking that the child is a single
CMARK_NODE_TEXT node with a non-empty destination. On [*a*](mailto:),
that passed NULL to strncmp() (C undefined behavior, caught by UBSan)
and wrapped \emph{a} in \nolinkurl{} when execution continued. Links
with trailing inlines like [http://example.com*foo*](http://example.com)
dropped *foo* (or wrapped it in \nolinkurl{} for mailto:), and code-span
links like [`http://example.com`](http://example.com) dropped \texttt{}
because CMARK_NODE_CODE also populates data and len. Check that
link_text is the sole child with type CMARK_NODE_TEXT and that
realurllen > 0 before calling strncmp(), and add regression cases to
render_latex in api_test/main.c.
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.
get_link_type()insrc/latex.ccompares the URL against a link's first child without checking that it's a single text node, so non-autolink inputs match. On[*a*](mailto:), it passesNULLtostrncmp()(undefined behavior, caught by UBSan) and wraps\emph{a}in\nolinkurl{}when execution continues. Trailing inlines like[http://example.com*foo*](http://example.com)drop*foo*(or wrap it in\nolinkurl{}onmailto:links), and[`http://example.com`](http://example.com)drops\texttt{}becauseCMARK_NODE_CODEalso setsdataandlen.I updated
get_link_type()to require a singleCMARK_NODE_TEXTchild and a positive remaining URL length, and added regression cases inapi_test/main.c. All seven bug cases fail onmaster. Plain autolinks stay intact, and the static and sharedctestsuites pass under ASan, UBSan, and Release.