Add static check in BN_hex2bn

Fixes #17298

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17299)
This commit is contained in:
Kan 2021-12-17 00:35:32 +08:00 committed by Pauli
parent a595e3286a
commit 7c78bd4be8

View File

@ -154,6 +154,10 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
return 0;
} else {
ret = *bn;
if (BN_get_flags(ret, BN_FLG_STATIC_DATA)) {
ERR_raise(ERR_LIB_BN, ERR_R_PASSED_INVALID_ARGUMENT);
return 0;
}
BN_zero(ret);
}