Skip to content

Commit

Permalink
CMP app: fix deallocated host/port fields in APP_HTTP_TLS_INFO
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #20034)

(cherry picked from commit 20d4dc8)
  • Loading branch information
DDvO authored and hlandau committed May 10, 2023
1 parent 6ce19b7 commit bda08b9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bda08b9

Please sign in to comment.