diff options
author | Jack Lloyd <[email protected]> | 2018-12-02 14:43:30 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-02 14:43:30 -0500 |
commit | 7bc0745c3ff2824f9a3607db19e7e1a3e563c5bc (patch) | |
tree | 299750773737c9e89673a57a56d717ac467f9909 /src/lib/math | |
parent | 387781c309596824b6cde965ba61bfa8a62c1817 (diff) |
Fix a bug in bigint_sub_abs
If one of the values had leading zero words, this could end up
calling bigint_sub with x_size < y_size.
OSS-Fuzz 11664 and 11656
Diffstat (limited to 'src/lib/math')
-rw-r--r-- | src/lib/math/mp/mp_core.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/math/mp/mp_core.h b/src/lib/math/mp/mp_core.h index d01c13a5e..4c08a0a23 100644 --- a/src/lib/math/mp/mp_core.h +++ b/src/lib/math/mp/mp_core.h @@ -679,6 +679,13 @@ bigint_sub_abs(word z[], std::swap(x_size, y_size); } + /* + * We know at this point that x >= y so if y_size is larger than + * x_size, we are guaranteed they are just leading zeros which can + * be ignored + */ + y_size = std::min(x_size, y_size); + bigint_sub3(z, x, x_size, y, y_size); return relative_size; |