From b591536e935a431b7f0a7a917ee04d62bd8b81d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Sat, 24 Jun 2017 02:17:45 +0200 Subject: [PATCH] Fix potential crash/wrong result two hashes of unequal length are compared --- src/libutil/hash.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index fa1bb5d97..e6f8aa85c 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;