diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2023-01-16 15:48:24 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-05-10 18:36:51 +0100 |
commit | 331e4d1250ff2cc96ebcaac333f71e2da597059a (patch) | |
tree | fb1d06c4b9c3774a7bf007b689054e6c220a31cf /apps | |
parent | deb7be7f1c9ca77fdc3ea1ebfc0229496eeb2a35 (diff) |
CMP app: fix deallocated host/port fields in APP_HTTP_TLS_INFO
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20034)
(cherry picked from commit 20d4dc8898edc12806ead2100ac09b907662aff6)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/cmp.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/cmp.c b/apps/cmp.c index 2d69d0cfd3..f9fc997253 100644 --- a/apps/cmp.c +++ b/apps/cmp.c @@ -1956,12 +1956,14 @@ static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine) if ((info = OPENSSL_zalloc(sizeof(*info))) == NULL) goto err; (void)OSSL_CMP_CTX_set_http_cb_arg(ctx, info); + info->ssl_ctx = setup_ssl_ctx(ctx, host, engine); info->server = host; - info->port = server_port; + host = NULL; /* prevent deallocation */ + if ((info->port = OPENSSL_strdup(server_port)) == NULL) + goto err; /* workaround for callback design flaw, see #17088: */ info->use_proxy = proxy_host != NULL; info->timeout = OSSL_CMP_CTX_get_option(ctx, OSSL_CMP_OPT_MSG_TIMEOUT); - info->ssl_ctx = setup_ssl_ctx(ctx, host, engine); if (info->ssl_ctx == NULL) goto err; @@ -3049,7 +3051,11 @@ int cmp_main(int argc, char **argv) /* cannot free info already here, as it may be used indirectly by: */ OSSL_CMP_CTX_free(cmp_ctx); #ifndef OPENSSL_NO_SOCK - APP_HTTP_TLS_INFO_free(info); + if (info != NULL) { + OPENSSL_free((char *)info->server); + OPENSSL_free((char *)info->port); + APP_HTTP_TLS_INFO_free(info); + } #endif } X509_VERIFY_PARAM_free(vpm); |