diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-12-16 17:41:56 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-12-16 17:41:56 +0100 |
commit | 14d82baba4ebb82df28c2d4e9517f8c3a81d8f6c (patch) | |
tree | b3884d3da5c581c145678ce83b62f21657f50bc3 /nix-rust/src/store | |
parent | 410acd29c046ae7296d882ee4750441d4ff29955 (diff) |
StorePath::new(): Check store directory
Diffstat (limited to 'nix-rust/src/store')
-rw-r--r-- | nix-rust/src/store/path.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/nix-rust/src/store/path.rs b/nix-rust/src/store/path.rs index 2a2232475..2a5170bef 100644 --- a/nix-rust/src/store/path.rs +++ b/nix-rust/src/store/path.rs @@ -13,8 +13,10 @@ pub const STORE_PATH_HASH_BYTES: usize = 20; pub const STORE_PATH_HASH_CHARS: usize = 32; impl StorePath { - pub fn new(path: &Path, _store_dir: &str) -> Result<Self, Error> { - // FIXME: check store_dir + pub fn new(path: &Path, store_dir: &Path) -> Result<Self, Error> { + if path.parent() != Some(store_dir) { + return Err(Error::NotInStore(path.into())); + } Self::new_from_base_name( path.file_name() .ok_or(Error::BadStorePath(path.into()))? |