Skip to content

Commit c4b0a89

Browse files
committed
unsquashfs: Improve error for invalid image
1 parent b05debe commit c4b0a89

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

backhand-cli/src/bin/unsquashfs.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,14 @@ fn main() -> ExitCode {
205205
return ExitCode::SUCCESS;
206206
}
207207

208-
let squashfs = Squashfs::from_reader_with_offset_and_kind(file, args.offset, kind).unwrap();
208+
let squashfs = match Squashfs::from_reader_with_offset_and_kind(file, args.offset, kind) {
209+
Ok(s) => s,
210+
Err(_e) => {
211+
let line = format!("{:>14}", red_bold.apply_to(format!("Could not read image: {_e}")));
212+
pb.finish_with_message(line);
213+
return ExitCode::FAILURE;
214+
}
215+
};
209216
let root_process = unsafe { geteuid() == 0 };
210217
if root_process {
211218
umask(Mode::from_bits(0).unwrap());

0 commit comments

Comments
 (0)