about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2016-12-13T14·41-0500
committerShea Levy <shea@shealevy.com>2016-12-13T14·41-0500
commitf867f090ed198e0e7f7e2db32b9e282883bf63b7 (patch)
tree3b803d37390de204d0cb3197d182d64e07847147 /src
parent05f907787fdc1903af0366d72cf6c30e9835182d (diff)
parent818aad3ec44473b5b3d08191488c824688653ba1 (diff)
Merge branch 'base32-overflow' of git://github.com/vcunat/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;