From 781ac11c6a7c08e7e18faae5897d60cd32b74f69 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 9 Aug 2019 11:49:06 +0200 Subject: [PATCH] src/backup/data_blob.rs: define const MAX_BLOB_SIZE --- src/backup/data_blob.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backup/data_blob.rs b/src/backup/data_blob.rs index 80d019bd..35bf88bd 100644 --- a/src/backup/data_blob.rs +++ b/src/backup/data_blob.rs @@ -3,6 +3,8 @@ use std::convert::TryInto; use proxmox::tools::io::{ReadExt, WriteExt}; +const MAX_BLOB_SIZE: usize = 128*1024*1024; + use super::*; /// Data blob binary storage format @@ -69,7 +71,7 @@ impl DataBlob { compress: bool, ) -> Result { - if data.len() > 128*1024*1024 { + if data.len() > MAX_BLOB_SIZE { bail!("data blob too large ({} bytes).", data.len()); } @@ -163,7 +165,7 @@ impl DataBlob { return Ok(self.raw_data[data_start..].to_vec()); } else if magic == &COMPRESSED_BLOB_MAGIC_1_0 { let data_start = std::mem::size_of::(); - let data = zstd::block::decompress(&self.raw_data[data_start..], 16*1024*1024)?; + let data = zstd::block::decompress(&self.raw_data[data_start..], MAX_BLOB_SIZE)?; return Ok(data); } else if magic == &ENCR_COMPR_BLOB_MAGIC_1_0 || magic == &ENCRYPTED_BLOB_MAGIC_1_0 { let header_len = std::mem::size_of::(); @@ -215,7 +217,7 @@ impl DataBlob { compress: bool, ) -> Result { - if data.len() > 128*1024*1024 { + if data.len() > MAX_BLOB_SIZE { bail!("data blob too large ({} bytes).", data.len()); }