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

This commit is contained in:
Eelco Dolstra 2016-07-21 18:35:12 +02:00
parent e682a8e138
commit ea8e8df6c7
2 changed files with 3 additions and 2 deletions

View file

@ -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

View file

@ -121,6 +121,7 @@ const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
string printHash32(const Hash & hash)
{
assert(hash.type != htUnknown);
size_t len = hash.base32Len();
assert(len);