Add Minh and Ander

-----Original Message-----
From: khanh.h.dang <khanh.h.d...@dektech.com.au> 
Sent: Thursday, February 21, 2019 9:46 AM
To: canh.v.tru...@dektech.com.au
Cc: opensaf-devel@lists.sourceforge.net; khanh.h.dang
<khanh.h.d...@dektech.com.au>
Subject: [PATCH 1/1] log: Allow hyphen character "-" in trace file name
[#3009]

Allow hyphen character when naming trace file as this satisfies
ValidateLogName method rule.
---
 src/dtm/transport/log_server.cc | 4 ++--
 src/dtm/transport/log_server.h  | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/dtm/transport/log_server.cc
b/src/dtm/transport/log_server.cc
index bef1f07..43fa86a 100644
--- a/src/dtm/transport/log_server.cc
+++ b/src/dtm/transport/log_server.cc
@@ -186,12 +186,12 @@ bool LogServer::ReadConfig(const char
*transport_config_file) {
 
 bool LogServer::ValidateLogName(const char* msg_id, size_t msg_id_size) {
   if (msg_id_size < 1 || msg_id_size > LogStream::kMaxLogNameSize) return
false;
-  if (msg_id[0] == '.') return false;
+  if (msg_id[0] == '.' || msg_id[0] == '-') return false;
   size_t no_of_dots = 0;
   for (size_t i = 0; i != msg_id_size; ++i) {
     char c = msg_id[i];
     if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
-          (c >= '0' && c <= '9') || (c == '.' || c == '_')))
+          (c >= '0' && c <= '9') || (c == '.' || c == '_' || c == '-')))
       return false;
     if (c == '.') ++no_of_dots;
   }
diff --git a/src/dtm/transport/log_server.h b/src/dtm/transport/log_server.h
index bbc3af8..283509c 100644
--- a/src/dtm/transport/log_server.h
+++ b/src/dtm/transport/log_server.h
@@ -81,8 +81,9 @@ class LogServer {
   // Validate the log stream name, for security reasons. This method will
check
   // that the string, when used as a file name, does not traverse the
directory
   // structure (e.g. ../../../etc/passwd would be an illegal log stream
-  // name). File names starting with a dot are also disallowed, since they
would
-  // result in hidden files.
+  // name). File names starting with a dot or a hyphen are also disallowed,
+  // since they would result in hidden files and the hyphen can be
+  // interpreted as an command line option.
   static bool ValidateLogName(const char* msg_id, size_t msg_id_size);
   void ExecuteCommand(const char* command, size_t size,
                       const struct sockaddr_un& addr, socklen_t addrlen);
-- 
2.7.4




_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to