Browse Source

LibCrypto: memcmp() all bytes in UnsignedBigInteger::operator==

`length` is only the (trimmed) size of the word vector, so we have to
multiply it with the size of each element to ensure all bytes are
compared.

Fixes #5335.
Linus Groh 4 years ago
parent
commit
1c6fd749dc
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp

+ 1 - 1
Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp

@@ -281,7 +281,7 @@ bool UnsignedBigInteger::operator==(const UnsignedBigInteger& other) const
     if (length != other.trimmed_length())
         return false;
 
-    return !__builtin_memcmp(m_words.data(), other.words().data(), length);
+    return !__builtin_memcmp(m_words.data(), other.words().data(), length * (BITS_IN_WORD / 8));
 }
 
 bool UnsignedBigInteger::operator!=(const UnsignedBigInteger& other) const