all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] tape: changer: handle invalid descriptor data from library in status page
@ 2021-07-26  7:20 Dominik Csapak
  2021-07-26  8:06 ` [pbs-devel] applied: " Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2021-07-26  7:20 UTC (permalink / raw)
  To: pbs-devel

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@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] tape: changer: handle invalid descriptor data from library in status page
  2021-07-26  7:20 [pbs-devel] [PATCH proxmox-backup] tape: changer: handle invalid descriptor data from library in status page Dominik Csapak
@ 2021-07-26  8:06 ` Dietmar Maurer
  0 siblings, 0 replies; 2+ messages in thread
From: Dietmar Maurer @ 2021-07-26  8:06 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

applied




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-26  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26  7:20 [pbs-devel] [PATCH proxmox-backup] tape: changer: handle invalid descriptor data from library in status page Dominik Csapak
2021-07-26  8:06 ` [pbs-devel] applied: " Dietmar Maurer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal