crypto/x509/by_store.c: Add check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18593)
This commit is contained in:
Jiasheng Jiang 2022-06-17 17:07:15 +08:00 committed by Pauli
parent 9f40251da8
commit e163969d35

View File

@ -119,12 +119,16 @@ static int by_store_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argp,
{
STACK_OF(OPENSSL_STRING) *uris = X509_LOOKUP_get_method_data(ctx);
char *data = OPENSSL_strdup(argp);
if (data == NULL) {
return 0;
}
if (uris == NULL) {
uris = sk_OPENSSL_STRING_new_null();
X509_LOOKUP_set_method_data(ctx, uris);
}
return sk_OPENSSL_STRING_push(uris, OPENSSL_strdup(argp)) > 0;
return sk_OPENSSL_STRING_push(uris, data) > 0;
}
case X509_L_LOAD_STORE:
/* This is a shortcut for quick loading of specific containers */