Merge branch 'base32-overflow' of git://github.com/vcunat/nix

This commit is contained in:
Shea Levy 2016-12-13 09:41:02 -05:00
commit f867f090ed

View file

@ -165,7 +165,13 @@ Hash parseHash32(HashType ht, const string & s)
unsigned int i = b / 8; unsigned int i = b / 8;
unsigned int j = b % 8; unsigned int j = b % 8;
hash.hash[i] |= digit << j; hash.hash[i] |= digit << j;
if (i < hash.hashSize - 1) hash.hash[i + 1] |= digit >> (8 - j);
if (i < hash.hashSize - 1) {
hash.hash[i + 1] |= digit >> (8 - j);
} else {
if (digit >> (8 - j))
throw BadHash(format("invalid base-32 hash %1%") % s);
}
} }
return hash; return hash;