Skip to content

fix: bugs found by fuzz/ - #232

Open
tvanderstad wants to merge 7 commits into
mitex-rs:mainfrom
lockbook:travis/fuzz-findings
Open

tvanderstad wants to merge 7 commits into
mitex-rs:mainfrom
lockbook:travis/fuzz-findings

Conversation

@tvanderstad

Copy link
Copy Markdown

I ran the afl harness in fuzz/ for 90 seconds and found 4 panics and 1 infinite loop:

  • panics: \begin{tabular} a \end{tabular}, \newcommand{\begin{matrix}_, \newcommand{\x}{a#}\x, __\limits
  • infinite loop: \newcommand{\x}{\x}\x

Each panic takes the form of assuming an input is valid. For example, \begin{tabular} a \end{tabular}: the parser expects a second {lcr} argument after \begin{tabular}, and when it gets a instead it panics trying to slice one character off each end. The fixes come with tests that fail without this PR's changes and pass with. One is already fixed by #226 so I left it out.

The loop is a somewhat annoying case where \newcommand{\x}{\x}\x defines \x as itself and then uses it. The fix is a 5 KB MAX_EXPANDED_BYTES, the same as MathJax's maxBuffer; I tried a few big arXiv papers and nothing exceeded 1.3 KB.

These changes were written by Claude Opus 5.5 Medium so I cannot vouch for them other than the evidence I've presented.

A macro that references itself, directly, mutually, through its arguments
or through an environment, expanded forever. One conversion may now expand
macro definitions and substituted arguments to at most 5 KB, MathJax's
maxBuffer; environment bodies are copied from the source and do not count.
The most macro-heavy of six arXiv papers expands to 1.3 KB.

This branch has not been deployed

No deployments
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.

1 participant