Skip to content

Commit

Permalink
embed.rs: Added error check when ISO file incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
RishabhSaini committed Jun 30, 2022
1 parent 6366c80 commit f820dab
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/live/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,25 @@ impl KargEmbedAreas {
);
}

let all_paths: Vec<String> = iso.walk()
.unwrap()
.map(|v| v.unwrap().0)
.collect::<Vec<String>>();
let mut all_files: Vec<iso9660::File> = Vec::new();
for path in all_paths {
if path.contains('.'){
let file = iso.get_path(&path)
.with_context(|| format!("looking up '{:?}'", path))?
.try_into_file()?;
all_files.push(file);
}
}
all_files.sort_by_key(|d| d.address.as_offset());
if all_files.last().unwrap().address.as_offset() + u64::from(all_files.last().unwrap().length) > iso.as_file()?.metadata()?.len() {
bail!("ISO Image is wrong and can't be modified");
}


// writable regions
let mut regions = Vec::new();
for loc in info.files {
Expand Down

0 comments on commit f820dab

Please sign in to comment.