Skip to content
Snippets Groups Projects
Commit ea8e8df6 authored by Eelco Dolstra's avatar Eelco Dolstra
Browse files

NarInfo::NarInfo(): Ensure that we get a NAR size/hash

parent e682a8e1
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ namespace nix { ...@@ -6,7 +6,7 @@ namespace nix {
NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence) NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
{ {
auto corrupt = [&]() { 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) { auto parseHashField = [&](const string & s) {
...@@ -73,7 +73,7 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & ...@@ -73,7 +73,7 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string &
if (compression == "") compression = "bzip2"; 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 std::string NarInfo::to_string() const
......
...@@ -121,6 +121,7 @@ const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz"; ...@@ -121,6 +121,7 @@ const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
string printHash32(const Hash & hash) string printHash32(const Hash & hash)
{ {
assert(hash.type != htUnknown);
size_t len = hash.base32Len(); size_t len = hash.base32Len();
assert(len); assert(len);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment