diff options
author | Shea Levy <shea@shealevy.com> | 2016-12-13 09:41:02 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2016-12-13 09:41:02 -0500 |
commit | f867f090ed198e0e7f7e2db32b9e282883bf63b7 (patch) | |
tree | 3b803d37390de204d0cb3197d182d64e07847147 | |
parent | 05f907787fdc1903af0366d72cf6c30e9835182d (diff) | |
parent | 818aad3ec44473b5b3d08191488c824688653ba1 (diff) |
Merge branch 'base32-overflow' of git://github.com/vcunat/nix
-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 81aced0fd..aa50fceb9 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; |