1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 18:31:49 +02:00

LocalStore::addToStore: Verify hash of the imported path

This commit is contained in:
Eelco Dolstra 2016-05-30 13:44:09 +02:00
parent e222484401
commit 12ddbad458
2 changed files with 6 additions and 1 deletions

View file

@ -904,6 +904,11 @@ void LocalStore::invalidatePath(State & state, const Path & path)
void LocalStore::addToStore(const ValidPathInfo & info, const std::string & nar, bool repair)
{
Hash h = hashString(htSHA256, nar);
if (h != info.narHash)
throw Error(format("hash mismatch importing path %s; expected hash %s, got %s") %
info.path % info.narHash.to_string() % h.to_string());
addTempRoot(info.path);
if (repair || !isValidPath(info.path)) {