This is an automated email from the ASF dual-hosted git repository. rrm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new e99f33c26 Fixes leak of sni config filename on load (#8821) e99f33c26 is described below commit e99f33c2635eac8e3894b71a3afe45c36844e25c Author: Randall Meyer <r...@apache.org> AuthorDate: Thu May 5 11:47:05 2022 -0700 Fixes leak of sni config filename on load (#8821) --- iocore/net/P_SSLSNI.h | 1 - iocore/net/SSLSNIConfig.cc | 16 ++++++++-------- iocore/net/YamlSNIConfig.cc | 2 +- iocore/net/YamlSNIConfig.h | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/iocore/net/P_SSLSNI.h b/iocore/net/P_SSLSNI.h index 8083e07b0..8897d0dbc 100644 --- a/iocore/net/P_SSLSNI.h +++ b/iocore/net/P_SSLSNI.h @@ -100,7 +100,6 @@ typedef std::vector<actionElement> SNIList; typedef std::vector<NextHopItem> NextHopPropertyList; struct SNIConfigParams : public ConfigInfo { - char *sni_filename = nullptr; SNIList sni_action_list; NextHopPropertyList next_hop_list; YamlSNIConfig Y_sni; diff --git a/iocore/net/SSLSNIConfig.cc b/iocore/net/SSLSNIConfig.cc index 809e419cb..2d069f256 100644 --- a/iocore/net/SSLSNIConfig.cc +++ b/iocore/net/SSLSNIConfig.cc @@ -156,14 +156,14 @@ SNIConfigParams::get(std::string_view servername) const int SNIConfigParams::Initialize() { - sni_filename = ats_stringdup(RecConfigReadConfigPath("proxy.config.ssl.servername.filename")); + std::string sni_filename = RecConfigReadConfigPath("proxy.config.ssl.servername.filename"); - Note("%s loading ...", sni_filename); + Note("%s loading ...", sni_filename.c_str()); struct stat sbuf; - if (stat(sni_filename, &sbuf) == -1 && errno == ENOENT) { - Note("%s failed to load", sni_filename); - Warning("Loading SNI configuration - filename: %s doesn't exist", sni_filename); + if (stat(sni_filename.c_str(), &sbuf) == -1 && errno == ENOENT) { + Note("%s failed to load", sni_filename.c_str()); + Warning("Loading SNI configuration - filename: %s doesn't exist", sni_filename.c_str()); return 1; } @@ -173,16 +173,16 @@ SNIConfigParams::Initialize() std::stringstream errMsg; errMsg << zret; if (TSSystemState::is_initializing()) { - Emergency("%s failed to load: %s", sni_filename, errMsg.str().c_str()); + Emergency("%s failed to load: %s", sni_filename.c_str(), errMsg.str().c_str()); } else { - Error("%s failed to load: %s", sni_filename, errMsg.str().c_str()); + Error("%s failed to load: %s", sni_filename.c_str(), errMsg.str().c_str()); } return 1; } Y_sni = std::move(Y_sni_tmp); loadSNIConfig(); - Note("%s finished loading", sni_filename); + Note("%s finished loading", sni_filename.c_str()); return 0; } diff --git a/iocore/net/YamlSNIConfig.cc b/iocore/net/YamlSNIConfig.cc index a5d277837..6ee194af3 100644 --- a/iocore/net/YamlSNIConfig.cc +++ b/iocore/net/YamlSNIConfig.cc @@ -61,7 +61,7 @@ load_tunnel_alpn(std::vector<int> &dst, const YAML::Node &node) } // namespace ts::Errata -YamlSNIConfig::loader(const char *cfgFilename) +YamlSNIConfig::loader(const std::string &cfgFilename) { try { YAML::Node config = YAML::LoadFile(cfgFilename); diff --git a/iocore/net/YamlSNIConfig.h b/iocore/net/YamlSNIConfig.h index 700e740cf..13887b683 100644 --- a/iocore/net/YamlSNIConfig.h +++ b/iocore/net/YamlSNIConfig.h @@ -96,7 +96,7 @@ struct YamlSNIConfig { void EnableProtocol(YamlSNIConfig::TLSProtocol proto); }; - ts::Errata loader(const char *cfgFilename); + ts::Errata loader(const std::string &cfgFilename); std::vector<YamlSNIConfig::Item> items; };