public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup v2] tape: mam: actually enforcing the length when writing attributes
@ 2024-05-24 13:29 Dominik Csapak
  0 siblings, 0 replies; only message in thread
From: Dominik Csapak @ 2024-05-24 13:29 UTC (permalink / raw)
  To: pbs-devel

we have to check against the length of the attribute, not the u16
maximum value. also improve the log output to tell the user what
the actual length was

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* include the lengths in the error message
 pbs-tape/src/sg_tape/mam.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/pbs-tape/src/sg_tape/mam.rs b/pbs-tape/src/sg_tape/mam.rs
index 4e995d0b..d8398e58 100644
--- a/pbs-tape/src/sg_tape/mam.rs
+++ b/pbs-tape/src/sg_tape/mam.rs
@@ -169,8 +169,12 @@ pub fn write_mam_attribute<F: AsRawFd>(
     attr_data.extend(data);
     if !data.is_empty() && data.len() < attribute.len as usize {
         attr_data.resize(attr_data.len() - data.len() + attribute.len as usize, 0);
-    } else if data.len() > u16::MAX as usize {
-        bail!("data to long");
+    } else if data.len() > attribute.len as usize {
+        bail!(
+            "attribute data length {} over the maximum allowed length {}",
+            data.len(),
+            attribute.len
+        );
     }
 
     parameters.extend(attr_data);
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-24 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24 13:29 [pbs-devel] [PATCH proxmox-backup v2] tape: mam: actually enforcing the length when writing attributes Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal