LibWasm: Disallow out-of-range br_table labels
This commit is contained in:
parent
8668851cb1
commit
b005691497
Notes:
sideshowbarker
2024-07-17 06:45:52 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/b005691497 Pull-request: https://github.com/SerenityOS/serenity/pull/19623 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/DanShaders
1 changed files with 2 additions and 0 deletions
|
@ -2112,6 +2112,8 @@ VALIDATE_INSTRUCTION(br_table)
|
|||
auto stack_to_check = stack_snapshot;
|
||||
for (auto& label : args.labels) {
|
||||
auto& label_types = m_context.labels[label.value()].types();
|
||||
if (label_types.size() != arity)
|
||||
return Errors::invalid("br_table label arity mismatch"sv);
|
||||
for (size_t i = 0; i < arity; ++i)
|
||||
TRY(stack_to_check.take(label_types[label_types.size() - i - 1]));
|
||||
stack_to_check = stack_snapshot;
|
||||
|
|
Loading…
Add table
Reference in a new issue