diff options
author | Shea Levy <shea@shealevy.com> | 2016-12-13T14·41-0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2016-12-13T14·41-0500 |
commit | f867f090ed198e0e7f7e2db32b9e282883bf63b7 (patch) | |
tree | 3b803d37390de204d0cb3197d182d64e07847147 /src | |
parent | 05f907787fdc1903af0366d72cf6c30e9835182d (diff) | |
parent | 818aad3ec44473b5b3d08191488c824688653ba1 (diff) |
Merge branch 'base32-overflow' of git://github.com/vcunat/nix
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/hash.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 81aced0fde16..aa50fceb9e3e 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -165,7 +165,13 @@ Hash parseHash32(HashType ht, const string & s) unsigned int i = b / 8; unsigned int j = b % 8; 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; |