mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
chore: Harden instructions and program (#535)
Also enforce sane limits in program Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
49958c2ece
commit
28891ef883
@@ -18,6 +18,7 @@ use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use anyhow::anyhow;
|
||||
|
||||
impl<'a> Compiler<'a> {
|
||||
pub(super) fn emit_return(&mut self, result_reg: super::Register) {
|
||||
@@ -38,8 +39,8 @@ impl<'a> Compiler<'a> {
|
||||
self.program.main_entry_point = 0;
|
||||
|
||||
self.program.max_rule_window_size =
|
||||
self.rule_num_registers.iter().cloned().max().unwrap_or(0) as usize;
|
||||
self.program.dispatch_window_size = self.register_counter as usize;
|
||||
self.rule_num_registers.iter().cloned().max().unwrap_or(0);
|
||||
self.program.dispatch_window_size = self.register_counter;
|
||||
|
||||
let mut rule_infos_map = BTreeMap::new();
|
||||
|
||||
@@ -140,6 +141,10 @@ impl<'a> Compiler<'a> {
|
||||
.map_err(CompilerError::from)?;
|
||||
}
|
||||
|
||||
self.program
|
||||
.validate_limits()
|
||||
.map_err(|e| CompilerError::from(anyhow!(e)))?;
|
||||
|
||||
Ok(self.program)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user