@@ -101,7 +101,7 @@ namespace modsecurity {
101101 */
102102Transaction::Transaction (ModSecurity *ms, RulesSet *rules, void *logCbData)
103103 : m_creationTimeStamp(utils::cpu_seconds()),
104- m_clientIpAddress (" " ),
104+ /* m_clientIpAddress(nullptr), */
105105 m_httpVersion (" " ),
106106 m_serverIpAddress(" " ),
107107 m_uri(" " ),
@@ -174,7 +174,7 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData)
174174
175175Transaction::Transaction (ModSecurity *ms, RulesSet *rules, char *id, void *logCbData)
176176 : m_creationTimeStamp(utils::cpu_seconds()),
177- m_clientIpAddress(" " ),
177+ /* m_clientIpAddress(""), */
178178 m_httpVersion(" " ),
179179 m_serverIpAddress(" " ),
180180 m_uri(" " ),
@@ -309,17 +309,17 @@ void Transaction::debug(int level, std::string message) const {
309309 */
310310int Transaction::processConnection (const char *client, int cPort,
311311 const char *server, int sPort ) {
312- this -> m_clientIpAddress = client;
312+ m_clientIpAddress = std::unique_ptr<std::string>( new std::string ( client)) ;
313313 this ->m_serverIpAddress = server;
314314 this ->m_clientPort = cPort;
315315 this ->m_serverPort = sPort ;
316316 ms_dbg (4 , " Transaction context created." );
317317 ms_dbg (4 , " Starting phase CONNECTION. (SecRules 0)" );
318318
319319
320- m_variableRemoteHost.set (m_clientIpAddress, m_variableOffset);
320+ m_variableRemoteHost.set (* m_clientIpAddress. get () , m_variableOffset);
321321 m_variableUniqueID.set (m_id, m_variableOffset);
322- m_variableRemoteAddr.set (m_clientIpAddress, m_variableOffset);
322+ m_variableRemoteAddr.set (* m_clientIpAddress. get () , m_variableOffset);
323323 m_variableServerAddr.set (m_serverIpAddress, m_variableOffset);
324324 m_variableServerPort.set (std::to_string (this ->m_serverPort ),
325325 m_variableOffset);
@@ -1462,7 +1462,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
14621462 ss << utils::string::dash_if_empty (
14631463 m_variableRequestHeaders.resolveFirst (" Host" ).get ())
14641464 << " " ;
1465- ss << utils::string::dash_if_empty (this ->m_clientIpAddress . c_str ()) << " " ;
1465+ ss << utils::string::dash_if_empty (this ->m_clientIpAddress -> c_str ()) << " " ;
14661466 /* * TODO: Check variable */
14671467 variables::RemoteUser *r = new variables::RemoteUser (" REMOTE_USER" );
14681468 std::vector<const VariableValue *> l;
@@ -1640,7 +1640,7 @@ std::string Transaction::toJSON(int parts) {
16401640
16411641 yajl_gen_map_open (g);
16421642 /* Part: A (header mandatory) */
1643- LOGFY_ADD (" client_ip" , this ->m_clientIpAddress . c_str ());
1643+ LOGFY_ADD (" client_ip" , this ->m_clientIpAddress -> c_str ());
16441644 LOGFY_ADD (" time_stamp" , ts.c_str ());
16451645 LOGFY_ADD (" server_id" , uniqueId.c_str ());
16461646 LOGFY_ADD_NUM (" client_port" , m_clientPort);
0 commit comments