mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 20:42:11 +02:00
LibCrypto: Fix a bug in big int addition
There was a bug when dealing with a carry when the addition result for the current word was UINT32_MAX. This commit also adds a regression test for the bug.
This commit is contained in:
Notes:
sideshowbarker
2024-07-19 07:05:53 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/2843dce4984 Pull-request: https://github.com/SerenityOS/serenity/pull/1661 Reviewed-by: https://github.com/Dexesttp Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling
@@ -39,7 +39,7 @@ UnsignedBigInteger UnsignedBigInteger::add(const UnsignedBigInteger& other)
|
||||
u32 word_addition_result = shorter->m_words[i] + longer->m_words[i];
|
||||
u8 carry_out = 0;
|
||||
// if there was a carry, the result will be smaller than any of the operands
|
||||
if (word_addition_result < shorter->m_words[i]) {
|
||||
if (word_addition_result + carry < shorter->m_words[i]) {
|
||||
carry_out = 1;
|
||||
}
|
||||
if (carry) {
|
||||
|
||||
Reference in New Issue
Block a user