about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2017-06-24T00·17+0200
committerNiklas Hambüchen <mail@nh2.me>2017-06-24T00·17+0200
commitb591536e935a431b7f0a7a917ee04d62bd8b81d9 (patch)
tree01685cfa41a237e4815a48c4f39158790f9f1485 /src
parentc7346a275c4cdcb59b3961241ddc52b79452d716 (diff)
Fix potential crash/wrong result two hashes of unequal length are compared
Diffstat (limited to 'src')
-rw-r--r--src/libutil/hash.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index fa1bb5d97183..e6f8aa85c6d8 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -54,6 +54,8 @@ bool Hash::operator != (const Hash & h2) const
 
 bool Hash::operator < (const Hash & h) const
 {
+    if (hashSize < h.hashSize) return true;
+    if (hashSize > h.hashSize) return false;
     for (unsigned int i = 0; i < hashSize; i++) {
         if (hash[i] < h.hash[i]) return true;
         if (hash[i] > h.hash[i]) return false;