about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2017-07-10T16·09+0200
committerGitHub <noreply@github.com>2017-07-10T16·09+0200
commit9c00fa417923087be00e7ba6f3da6045692b41a1 (patch)
treeed814c739a4280003fa047ca86b3e07d683bd543 /src/libutil
parent62a8fe6388a1ee8f9376b8e65b0cb9a02c313e9f (diff)
parentb591536e935a431b7f0a7a917ee04d62bd8b81d9 (diff)
Merge pull request #1422 from nh2/fix-potential-hash-comparison-crash
Fix potential crash/wrong result two hashes of unequal length are compared
Diffstat (limited to 'src/libutil')
-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 6b45ac859d59..817ddc0b8bc9 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -45,6 +45,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;