Skip to content

Commit d59245d

Browse files
committed
tool: check number of domains does not exceed max
Signed-off-by: James Archer <j.archer@unsw.edu.au>
1 parent ed49ef8 commit d59245d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tool/microkit/src/sysxml.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const PD_MAX_PRIORITY: u8 = 254;
4141
/// In microseconds
4242
const BUDGET_DEFAULT: u64 = 1000;
4343

44+
/// The maximum number of domains supported by the kernel
45+
const DOMAIN_COUNT_MAX: u64 = 256;
46+
4447
/// The purpose of this function is to parse an integer that could
4548
/// either be in decimal or hex format, unlike the normal parsing
4649
/// functionality that the Rust standard library provides.
@@ -840,6 +843,12 @@ impl DomainSchedule {
840843
loc_string(xml_sdf, pos)
841844
));
842845
}
846+
if domain_names.size() > DOMAIN_COUNT_MAX {
847+
return Err(format!(
848+
"Error: number of domains in domain schedule exceeds maximum of 256: {}",
849+
loc_string(xml_sdf, pos)
850+
));
851+
}
843852

844853
let time = checked_lookup(xml_sdf, &child, "length")?.parse::<u64>();
845854
if let Err(_) = time {

0 commit comments

Comments
 (0)