Commit 1dbb2b74 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2874 from cremno/fix-parser-oob-write

Coverity: fix oob write by actually truncating buffer
parents b071dcd4 24583a7a
...@@ -3604,10 +3604,13 @@ toklast(parser_state *p) ...@@ -3604,10 +3604,13 @@ toklast(parser_state *p)
static void static void
tokfix(parser_state *p) tokfix(parser_state *p)
{ {
if (p->bidx >= MRB_PARSER_BUF_SIZE) { int i = p->bidx, imax = MRB_PARSER_BUF_SIZE - 1;
if (i > imax) {
i = imax;
yyerror(p, "string too long (truncated)"); yyerror(p, "string too long (truncated)");
} }
p->buf[p->bidx] = '\0'; p->buf[i] = '\0';
} }
static const char* static const char*
......
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