diff options
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/path.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libstore/path.cc b/src/libstore/path.cc index c896ff927..2f929b7b3 100644 --- a/src/libstore/path.cc +++ b/src/libstore/path.cc @@ -64,6 +64,11 @@ StorePath Store::parseStorePath(std::string_view path) const std::optional<StorePath> Store::maybeParseStorePath(std::string_view path) const { + // If it's not an absolute path, or if the dirname of the path isn't /nix/store + // (or whatever our storeDir is), then it can't be a store path. + if ((path.size() > 0 && path[0] != '/') || dirOf(canonPath(path)) != this->storeDir) { + return std::nullopt; + } try { return parseStorePath(path); } catch (Error &) { |