about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/nar-info.cc4
-rw-r--r--src/libutil/hash.cc1
2 files changed, 3 insertions, 2 deletions
diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc
index 1aacca84b800..b0a8d77c2fba 100644
--- a/src/libstore/nar-info.cc
+++ b/src/libstore/nar-info.cc
@@ -6,7 +6,7 @@ namespace nix {
 NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
 {
     auto corrupt = [&]() {
-        throw Error("NAR info file ‘%1%’ is corrupt");
+        throw Error(format("NAR info file ‘%1%’ is corrupt") % whence);
     };
 
     auto parseHashField = [&](const string & s) {
@@ -73,7 +73,7 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string &
 
     if (compression == "") compression = "bzip2";
 
-    if (path.empty() || url.empty()) corrupt();
+    if (path.empty() || url.empty() || narSize == 0 || !narHash) corrupt();
 }
 
 std::string NarInfo::to_string() const
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index fa42587777cd..5352483ff93b 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -121,6 +121,7 @@ const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
 
 string printHash32(const Hash & hash)
 {
+    assert(hash.type != htUnknown);
     size_t len = hash.base32Len();
     assert(len);