mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibCrypto+LibJS: Fix broken subtraction of two negative signed bigints
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29326
This commit is contained in:
Notes:
sideshowbarker
2024-07-19 00:03:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7ed89703fea
@@ -113,11 +113,11 @@ FLATTEN SignedBigInteger SignedBigInteger::minus(const SignedBigInteger& other)
|
||||
// -x - -y = y - x
|
||||
if (m_unsigned_data < other.m_unsigned_data) {
|
||||
// The result will be positive.
|
||||
return SignedBigInteger { m_unsigned_data.minus(other.m_unsigned_data) };
|
||||
return SignedBigInteger { other.m_unsigned_data.minus(m_unsigned_data), true };
|
||||
}
|
||||
// The result will be either zero, or negative.
|
||||
// y - x = - (x - y)
|
||||
return { other.m_unsigned_data.minus(m_unsigned_data), true };
|
||||
return SignedBigInteger { m_unsigned_data.minus(other.m_unsigned_data) };
|
||||
}
|
||||
|
||||
FLATTEN SignedBigInteger SignedBigInteger::plus(const UnsignedBigInteger& other) const
|
||||
|
||||
Reference in New Issue
Block a user