about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-05-30T11·44+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-05-30T13·18+0200
commit12ddbad45893f125e2ab46c5e26d7c8396b31bdb (patch)
treeca1536ed40b613bed58f49f90b9e1ec199ca769a /src/libstore/local-store.cc
parente2224844019d58fc947ce00e18e9fa9974d2c8b5 (diff)
LocalStore::addToStore: Verify hash of the imported path
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index acd02eb48adc..8608b39ec5bd 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -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)) {