From b724d44153b0d520607be690e3f38cc1531ed681 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 16 May 2022 09:16:46 +0200 Subject: [PATCH] api types: BackupNamespace: fix depth check on pushing subdir to ns Signed-off-by: Thomas Lamprecht --- pbs-api-types/src/datastore.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 4ccdaaa8..a3435c38 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -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 {