* Be stricter in verifying store paths.
This commit is contained in:
parent
87bf541f23
commit
a4d2b22c8c
|
@ -335,6 +335,7 @@ void ensurePath(const Path & path, PathSet pending)
|
|||
|
||||
StoreExpr storeExprFromPath(const Path & path, PathSet pending)
|
||||
{
|
||||
assertStorePath(path);
|
||||
ensurePath(path, pending);
|
||||
ATerm t = ATreadFromNamedFile(path.c_str());
|
||||
if (!t) throw Error(format("cannot read aterm from `%1%'") % path);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -48,6 +48,9 @@ Paths querySubstitutes(const Path & srcPath);
|
|||
/* Register the validity of a path. */
|
||||
void registerValidPath(const Transaction & txn, const Path & path);
|
||||
|
||||
/* Throw an exception if `path' is not directly in the Nix store. */
|
||||
void assertStorePath(const Path & path);
|
||||
|
||||
/* Checks whether a path is valid. */
|
||||
bool isValidPath(const Path & path);
|
||||
|
||||
|
|
Loading…
Reference in a new issue