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
This commit is contained in:
akallabeth 2021-10-06 09:17:59 +02:00 committed by GitHub
parent b3209fe2b9
commit 32994b02f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -120,6 +120,8 @@ int main(int argc, char* argv[])
pf_server_config_print(config); pf_server_config_print(config);
server = pf_server_new(config); server = pf_server_new(config);
pf_server_config_free(config);
if (!server) if (!server)
goto fail; goto fail;
@ -133,7 +135,6 @@ int main(int argc, char* argv[])
fail: fail:
pf_server_free(server); pf_server_free(server);
pf_server_config_free(config);
return status; return status;
} }

View File

@ -810,8 +810,8 @@ proxyServer* pf_server_new(const proxyConfig* config)
if (!pf_config_clone(&server->config, config)) if (!pf_config_clone(&server->config, config))
goto out; goto out;
server->module = pf_modules_new(FREERDP_PROXY_PLUGINDIR, pf_config_modules(config), server->module = pf_modules_new(FREERDP_PROXY_PLUGINDIR, pf_config_modules(server->config),
pf_config_modules_count(config)); pf_config_modules_count(server->config));
if (!server->module) if (!server->module)
{ {
WLog_ERR(TAG, "failed to initialize proxy modules!"); 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->info = server;
server->listener->PeerAccepted = pf_server_peer_accepted; 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; goto out;
return server; return server;