diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2016-12-15T11·31+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2016-12-15T11·31+0100 |
commit | 5278bb7c16c227d64551fc6578cb1b1b22f3b036 (patch) | |
tree | 1b5af104e7fadaf20b9caea9964e4a4da82ac192 /src | |
parent | 1df82b62456b3194b3d8be0562e886cf16bf9379 (diff) | |
parent | f867f090ed198e0e7f7e2db32b9e282883bf63b7 (diff) |
Merge branch 'master' of github.com:NixOS/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; |