read_ilang: do bounds checking on bit indices

This commit is contained in:
Marcin Kościelnicki 2019-11-27 22:24:39 +01:00
parent 6464dc35ec
commit 0ce22cea46
1 changed files with 4 additions and 0 deletions

View File

@ -430,10 +430,14 @@ sigspec:
free($1); free($1);
} | } |
sigspec '[' TOK_INT ']' { sigspec '[' TOK_INT ']' {
if ($3 >= $1->size() || $3 < 0)
rtlil_frontend_ilang_yyerror("bit index out of range");
$$ = new RTLIL::SigSpec($1->extract($3)); $$ = new RTLIL::SigSpec($1->extract($3));
delete $1; delete $1;
} | } |
sigspec '[' TOK_INT ':' TOK_INT ']' { sigspec '[' TOK_INT ':' TOK_INT ']' {
if ($3 >= $1->size() || $3 < 0 || $3 < $5)
rtlil_frontend_ilang_yyerror("invalid slice");
$$ = new RTLIL::SigSpec($1->extract($5, $3 - $5 + 1)); $$ = new RTLIL::SigSpec($1->extract($5, $3 - $5 + 1));
delete $1; delete $1;
} | } |