From 3a7ad4f03b62da6b9e2e5e30e1cba5ab7e36e7e9 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Wed, 19 Aug 2020 08:50:27 +1000 Subject: [PATCH] Check the error return from fp_mod in fp_gcd Error can occur when using small stack and memory allocation fails. --- wolfcrypt/src/tfm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index bf128174e..8c0a98866 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -5157,7 +5157,10 @@ int fp_gcd(fp_int *a, fp_int *b, fp_int *c) fp_init(r); while (fp_iszero(v) == FP_NO) { - fp_mod(u, v, r); + int err = fp_mod(u, v, r); + if (err != MP_OKAY) { + return err; + } fp_copy(v, u); fp_copy(r, v); }