From 68469eebb4bd3480621a2dfd650985737dcff111 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sun, 20 Jan 2019 16:49:22 +0100 Subject: [PATCH] backup/chunk_store.rs: verify base path is absolute --- src/backup/chunk_store.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backup/chunk_store.rs b/src/backup/chunk_store.rs index 87a041d1..5c6ad934 100644 --- a/src/backup/chunk_store.rs +++ b/src/backup/chunk_store.rs @@ -82,6 +82,11 @@ impl ChunkStore { pub fn create>(name: &str, path: P) -> Result { let base: PathBuf = path.into(); + + if !base.is_absolute() { + bail!("expected absolute path - got {:?}", base); + } + let chunk_dir = Self::chunk_dir(&base); if let Err(err) = std::fs::create_dir(&base) { @@ -114,6 +119,11 @@ impl ChunkStore { pub fn open>(name: &str, path: P) -> Result { let base: PathBuf = path.into(); + + if !base.is_absolute() { + bail!("expected absolute path - got {:?}", base); + } + let chunk_dir = Self::chunk_dir(&base); if let Err(err) = std::fs::metadata(&chunk_dir) {