From a18a63c827fb8ea06c6ecd21dff6f4c9529f9e70 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 17 May 2023 14:57:15 +0200 Subject: [PATCH] tape: avoid panic potential in MAM attribute decoder We already saw that quite some tape libraries/loaders/... ain't always _that_ standard conform, and even if it'd be guaranteed, it just makes no sense to create a potential for panicking the whole daemon due to some sub-features hiccup, rather go for actual error handling... Signed-off-by: Thomas Lamprecht --- pbs-tape/src/sg_tape/mam.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbs-tape/src/sg_tape/mam.rs b/pbs-tape/src/sg_tape/mam.rs index 5b7605d0..f8afbe7b 100644 --- a/pbs-tape/src/sg_tape/mam.rs +++ b/pbs-tape/src/sg_tape/mam.rs @@ -257,7 +257,7 @@ fn decode_mam_attributes(data: &[u8]) -> Result, Error> { format!("{}", u64::from_be_bytes(data[0..8].try_into()?)) } } else { - unreachable!(); + bail!("unexpected MAM attribute length {}", info.1); } } MamFormat::BINARY => hex::encode(&data),