[pbs-devel] [PATCH proxmox-backup] tape: changer: handle invalid descriptor data from library in status page
Dominik Csapak
d.csapak at proxmox.com
Mon Jul 26 09:20:41 CEST 2021
We get the descriptor length from the library and use that in
'chunks_exact', which panics on length 0. Catch that case
and bail out, since that makes no sense here anyway.
This could prevent a panic, in case a library sends wrong data.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/tape/changer/sg_pt_changer.rs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/tape/changer/sg_pt_changer.rs b/src/tape/changer/sg_pt_changer.rs
index c94eaf2e..3124b96f 100644
--- a/src/tape/changer/sg_pt_changer.rs
+++ b/src/tape/changer/sg_pt_changer.rs
@@ -710,7 +710,13 @@ fn decode_element_status_page(
let descr_data = reader.read_exact_allocated(len)?;
- for descriptor in descr_data.chunks_exact(subhead.descriptor_length as usize) {
+ let descr_len = subhead.descriptor_length as usize;
+
+ if descr_len == 0 {
+ bail!("got elements, but descriptor length 0");
+ }
+
+ for descriptor in descr_data.chunks_exact(descr_len) {
let mut reader = &descriptor[..];
match subhead.element_type_code {
--
2.30.2
More information about the pbs-devel
mailing list