trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gan...@apache.org
Subject [trafficserver] branch master updated: ASAN: stack-use-after-scope
Date Wed, 11 Jul 2018 20:46:35 GMT
This is an automated email from the ASF dual-hosted git repository.

gancho 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 7e5e6ed  ASAN: stack-use-after-scope
7e5e6ed is described below

commit 7e5e6ede04fd74056636ab928ed9078aa19fe87a
Author: Gancho Tenev <gancho@apache.org>
AuthorDate: Tue Jul 10 23:36:44 2018 -0700

    ASAN: stack-use-after-scope
    
    in YamlLogConfig::decodeLogObject(YAML::Node const&)
       const char *mode_str = node["mode"].as<std::string>().c_str();
    results in dangling mode_str pointer.
---
 proxy/logging/YamlLogConfig.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/proxy/logging/YamlLogConfig.cc b/proxy/logging/YamlLogConfig.cc
index e6b9e8c..dc93f1c 100644
--- a/proxy/logging/YamlLogConfig.cc
+++ b/proxy/logging/YamlLogConfig.cc
@@ -139,10 +139,10 @@ YamlLogConfig::decodeLogObject(const YAML::Node &node)
   // file format
   LogFileFormat file_type = LOG_FILE_ASCII; // default value
   if (node["mode"]) {
-    const char *mode_str = node["mode"].as<std::string>().c_str();
-    file_type            = (strncasecmp(mode_str, "bin", 3) == 0 || (mode_str[0] == 'b' &&
mode_str[1] == 0) ?
+    std::string mode = node["mode"].as<std::string>();
+    file_type        = (0 == strncasecmp(mode.c_str(), "bin", 3) || (1 == mode.size() &&
mode[0] == 'b') ?
                    LOG_FILE_BINARY :
-                   (strcasecmp(mode_str, "ascii_pipe") == 0 ? LOG_FILE_PIPE : LOG_FILE_ASCII));
+                   (0 == strcasecmp(mode.c_str(), "ascii_pipe") ? LOG_FILE_PIPE : LOG_FILE_ASCII));
   }
 
   int obj_rolling_enabled      = 0;


Mime
View raw message