diff --git a/src/MessageDigest.cc b/src/MessageDigest.cc index 278baa9b..7a09ed0f 100644 --- a/src/MessageDigest.cc +++ b/src/MessageDigest.cc @@ -135,9 +135,12 @@ bool MessageDigest::isStronger(const std::string& lhs, const std::string& rhs) FindHashTypeEntry(lhs)); auto rEntry = std::find_if(std::begin(hashTypes), std::end(hashTypes), FindHashTypeEntry(rhs)); - if(lEntry == std::end(hashTypes) || rEntry == std::end(hashTypes)) { + if(lEntry == std::end(hashTypes)) { return false; } + if(rEntry == std::end(hashTypes)) { + return true; + } return lEntry->strength > rEntry->strength; } diff --git a/test/MessageDigestTest.cc b/test/MessageDigestTest.cc index 6a2f9f1d..4608ca53 100644 --- a/test/MessageDigestTest.cc +++ b/test/MessageDigestTest.cc @@ -76,7 +76,7 @@ void MessageDigestTest::testIsStronger() CPPUNIT_ASSERT(MessageDigest::isStronger("sha-1", "md5")); CPPUNIT_ASSERT(!MessageDigest::isStronger("md5", "sha-1")); CPPUNIT_ASSERT(!MessageDigest::isStronger("unknown", "sha-1")); - CPPUNIT_ASSERT(!MessageDigest::isStronger("sha-1", "unknown")); + CPPUNIT_ASSERT(MessageDigest::isStronger("sha-1", "unknown")); } void MessageDigestTest::testIsValidHash()