api types: BackupNamespace: fix depth check on pushing subdir to ns

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-16 09:16:46 +02:00
parent 1f2126fd7c
commit 6bfc94ea19
1 changed files with 4 additions and 6 deletions

View File

@ -629,12 +629,10 @@ impl BackupNamespace {
/// Assumes `subdir` already does not contain any slashes.
/// Performs remaining checks and updates the length.
fn push_do(&mut self, subdir: String) -> Result<(), Error> {
if self.depth() > MAX_NAMESPACE_DEPTH {
bail!(
"namespace to deep, {} > max {}",
self.inner.len(),
MAX_NAMESPACE_DEPTH
);
let depth = self.depth();
// check for greater equal to account for the to be added subdir
if depth >= MAX_NAMESPACE_DEPTH {
bail!("namespace to deep, {depth} >= max {MAX_NAMESPACE_DEPTH}");
}
if self.len + subdir.len() + 1 > MAX_BACKUP_NAMESPACE_LENGTH {