Skip to content

Commit

Permalink
crypto/x509/by_store.c: Add check for OPENSSL_strdup
Browse files Browse the repository at this point in the history
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 #18593)

(cherry picked from commit e163969)
  • Loading branch information
JiangJias authored and paulidale committed Jun 22, 2022
1 parent c49100c commit 2814834
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crypto/x509/by_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 2814834

Please sign in to comment.