From 1c6fd749dc85edab13fdccd6cca81c50f2436603 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 14 Feb 2021 10:25:12 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp index ef838ec7825..63021614bb2 100644 --- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp +++ b/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