Skip to content

Commit

Permalink
tool: check number of domains does not exceed max
Browse files Browse the repository at this point in the history
Signed-off-by: James Archer <[email protected]>
  • Loading branch information
JE-Archer committed Jul 26, 2024
1 parent ed49ef8 commit 3913202
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tool/microkit/src/sysxml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const PD_MAX_PRIORITY: u8 = 254;
/// In microseconds
const BUDGET_DEFAULT: u64 = 1000;

/// The maximum number of domains supported by the kernel
const DOMAIN_COUNT_MAX: u64 = 256;

/// The purpose of this function is to parse an integer that could
/// either be in decimal or hex format, unlike the normal parsing
/// functionality that the Rust standard library provides.
Expand Down Expand Up @@ -840,6 +843,12 @@ impl DomainSchedule {
loc_string(xml_sdf, pos)
));
}
if domain_names.len() as u64 > DOMAIN_COUNT_MAX {
return Err(format!(
"Error: number of domains in domain schedule exceeds maximum of 256: {}",
loc_string(xml_sdf, pos)
));
}

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

0 comments on commit 3913202

Please sign in to comment.