From 32994b02f57943d0b3b08832ef055c7300bc3329 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 6 Oct 2021 09:17:59 +0200 Subject: [PATCH] Fix pf_server_new: pass own copy of proxyConfig (#7328) * Fix pf_server_new: pass own copy of proxyConfig The lifecycle of proxyConfig passed to pf_server_new is unknown, so pass proxyServer->config copy to modules. * Early free parsed proxyConfig --- server/proxy/cli/freerdp_proxy.c | 3 ++- server/proxy/pf_server.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/proxy/cli/freerdp_proxy.c b/server/proxy/cli/freerdp_proxy.c index 2a57826fc..f7b251c2e 100644 --- a/server/proxy/cli/freerdp_proxy.c +++ b/server/proxy/cli/freerdp_proxy.c @@ -120,6 +120,8 @@ int main(int argc, char* argv[]) pf_server_config_print(config); server = pf_server_new(config); + pf_server_config_free(config); + if (!server) goto fail; @@ -133,7 +135,6 @@ int main(int argc, char* argv[]) fail: pf_server_free(server); - pf_server_config_free(config); return status; } diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 703efa62b..5b7c7f164 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -810,8 +810,8 @@ proxyServer* pf_server_new(const proxyConfig* config) if (!pf_config_clone(&server->config, config)) goto out; - server->module = pf_modules_new(FREERDP_PROXY_PLUGINDIR, pf_config_modules(config), - pf_config_modules_count(config)); + server->module = pf_modules_new(FREERDP_PROXY_PLUGINDIR, pf_config_modules(server->config), + pf_config_modules_count(server->config)); if (!server->module) { WLog_ERR(TAG, "failed to initialize proxy modules!"); @@ -842,7 +842,7 @@ proxyServer* pf_server_new(const proxyConfig* config) server->listener->info = server; server->listener->PeerAccepted = pf_server_peer_accepted; - if (!pf_modules_add(server->module, pf_config_plugin, (void*)config)) + if (!pf_modules_add(server->module, pf_config_plugin, (void*)server->config)) goto out; return server;