mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
fix oob write by actually truncating buffer
Found by Coverity scan of polyfox-moon: CID 121927 (#1 of 1): Out-of-bounds write (OVERRUN)
This commit is contained in:
@@ -3604,10 +3604,13 @@ toklast(parser_state *p)
|
||||
static void
|
||||
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)");
|
||||
}
|
||||
p->buf[p->bidx] = '\0';
|
||||
p->buf[i] = '\0';
|
||||
}
|
||||
|
||||
static const char*
|
||||
|
||||
Reference in New Issue
Block a user