Fix bn_gcd code to check return value when calling BN_one()
authorslontis <shane.lontis@oracle.com>
Fri, 1 Jul 2022 03:47:11 +0000 (13:47 +1000)
committerRichard Levitte <levitte@openssl.org>
Tue, 5 Jul 2022 06:18:23 +0000 (08:18 +0200)
commit6495cab1c876ad80ce983d848ccaa1dc286a63e1
tree221ffb05ba597de80103208c4de3952d0bd9edeb
parent7a05fcb1fc276a7ecfe599d45655d4e617c5e2d4
Fix bn_gcd code to check return value when calling BN_one()

BN_one() uses the expand function which calls malloc which may fail.
All other places that reference BN_one() check the return value.

The issue is triggered by a memory allocation failure.
Detected by PR #18355

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18697)

(cherry picked from commit 7fe7cc57af3db1e497877f0329ba17609b2efc8b)
crypto/bn/bn_gcd.c