From a4d2b22c8ca5064f1da614914c7ea336eedd65c4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 14 Apr 2004 08:08:55 +0000 Subject: * Be stricter in verifying store paths. --- src/libstore/store.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/libstore/store.cc') diff --git a/src/libstore/store.cc b/src/libstore/store.cc index d85b0608f409..a89e4ed89fa7 100644 --- a/src/libstore/store.cc +++ b/src/libstore/store.cc @@ -160,13 +160,14 @@ void copyPath(const Path & src, const Path & dst) static bool isInStore(const Path & path) { return path[0] == '/' - && Path(path, 0, nixStore.size()) == nixStore - && path.size() > nixStore.size() + 1 - && path[nixStore.size()] == '/'; + && path.compare(0, nixStore.size(), nixStore) == 0 + && path.size() >= nixStore.size() + 2 + && path[nixStore.size()] == '/' + && path.find('/', nixStore.size() + 1) == Path::npos; } -static void assertStorePath(const Path & path) +void assertStorePath(const Path & path) { if (!isInStore(path)) throw Error(format("path `%1%' is not in the Nix store") % path); -- cgit 1.4.1