1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-02 15:11:00 +01:00

* Be stricter in verifying store paths.

This commit is contained in:
Eelco Dolstra 2004-04-14 08:08:55 +00:00
parent 87bf541f23
commit a4d2b22c8c
3 changed files with 9 additions and 4 deletions

View file

@ -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);