From b591536e935a431b7f0a7a917ee04d62bd8b81d9 Mon Sep 17 00:00:00 2001 From: Niklas Hambüchen Date: Sat, 24 Jun 2017 02:17:45 +0200 Subject: Fix potential crash/wrong result two hashes of unequal length are compared --- src/libutil/hash.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libutil') 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; -- cgit 1.4.1