aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/bigint
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-02-25 12:23:41 -0500
committerJack Lloyd <[email protected]>2018-02-25 12:23:41 -0500
commit4536e240238d0b0ecb896c11978b58df108a6ad3 (patch)
tree451605f4f7a3a64b919fcd2f9460f13a87fef3c4 /src/lib/math/bigint
parent896fd7d5d3ef2c4d546fbf0fecb1b1201d022202 (diff)
Pass workspace size to various bigint_ functions
These functions made assumptions about the workspace size available, which if incorrect would cause memory corruption. Since the length is always available at the caller, just provide it and avoid problems.
Diffstat (limited to 'src/lib/math/bigint')
-rw-r--r--src/lib/math/bigint/big_ops2.cpp2
-rw-r--r--src/lib/math/bigint/big_ops3.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp
index 639d87ceb..2f81989c3 100644
--- a/src/lib/math/bigint/big_ops2.cpp
+++ b/src/lib/math/bigint/big_ops2.cpp
@@ -119,7 +119,7 @@ BigInt& BigInt::operator*=(const BigInt& y)
{
grow_to(size() + y.size());
secure_vector<word> workspace(size());
- bigint_mul(*this, BigInt(*this), y, workspace.data());
+ bigint_mul(*this, BigInt(*this), y, workspace.data(), workspace.size());
}
return (*this);
diff --git a/src/lib/math/bigint/big_ops3.cpp b/src/lib/math/bigint/big_ops3.cpp
index 680eca635..8bff790a6 100644
--- a/src/lib/math/bigint/big_ops3.cpp
+++ b/src/lib/math/bigint/big_ops3.cpp
@@ -95,7 +95,7 @@ BigInt operator*(const BigInt& x, const BigInt& y)
else if(x_sw && y_sw)
{
secure_vector<word> workspace(z.size());
- bigint_mul(z, x, y, workspace.data());
+ bigint_mul(z, x, y, workspace.data(), workspace.size());
}
if(x_sw && y_sw && x.sign() != y.sign())