Commit 694e1b27 authored by Daniel Salzman's avatar Daniel Salzman

zscanner: add explicit comment length init to prevent index overflow (oss-fuzz, ubsan)

The index overflow can happen during multiline record parsing.
parent 5851bb8a
This diff is collapsed.
This diff is collapsed.
......@@ -41,6 +41,9 @@
s->multiline = false;
}
action _comment_init {
s->buffer_length = 0;
}
action _comment {
if (s->buffer_length < sizeof(s->buffer) - 1) {
s->buffer[s->buffer_length++] = fc;
......@@ -60,7 +63,7 @@
}
newline = '\n' $_newline;
comment = (';' . (^newline)* $_comment) %_comment_exit;
comment = (';' . (^newline)* $_comment) >_comment_init %_comment_exit;
# White space separation. With respect to parentheses and included comments.
sep = ( [ \t] # Blank characters.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment