about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2016-12-15T11·31+0100
committerEelco Dolstra <edolstra@gmail.com>2016-12-15T11·31+0100
commit5278bb7c16c227d64551fc6578cb1b1b22f3b036 (patch)
tree1b5af104e7fadaf20b9caea9964e4a4da82ac192 /src
parent1df82b62456b3194b3d8be0562e886cf16bf9379 (diff)
parentf867f090ed198e0e7f7e2db32b9e282883bf63b7 (diff)
Merge branch 'master' of github.com:NixOS/nix
Diffstat (limited to 'src')
-rw-r--r--src/libutil/hash.cc8
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;