Makes m_serverIpAddress a shared pointer

This commit is contained in:
Felipe Zimmerle
2019-01-22 15:18:25 -03:00
parent 8df35deadb
commit d7d5cd2a91
4 changed files with 16 additions and 14 deletions

View File

@@ -103,9 +103,9 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData)
: m_creationTimeStamp(utils::cpu_seconds()),
/* m_clientIpAddress(nullptr), */
m_httpVersion(""),
m_serverIpAddress(""),
/* m_serverIpAddress(""), */
m_uri(""),
m_uri_no_query_string_decoded(""),
/* m_uri_no_query_string_decoded(""), */
m_ARGScombinedSizeDouble(0),
m_clientPort(0),
m_highestSeverityAction(255),
@@ -176,9 +176,9 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, char *id, void *logCb
: m_creationTimeStamp(utils::cpu_seconds()),
/* m_clientIpAddress(""), */
m_httpVersion(""),
m_serverIpAddress(""),
/* m_serverIpAddress(""), */
m_uri(""),
m_uri_no_query_string_decoded(""),
/* m_uri_no_query_string_decoded(""), */
m_ARGScombinedSizeDouble(0),
m_clientPort(0),
m_highestSeverityAction(255),
@@ -310,7 +310,7 @@ void Transaction::debug(int level, std::string message) const {
int Transaction::processConnection(const char *client, int cPort,
const char *server, int sPort) {
m_clientIpAddress = std::unique_ptr<std::string>(new std::string(client));
this->m_serverIpAddress = server;
m_serverIpAddress = std::unique_ptr<std::string>(new std::string(server));
this->m_clientPort = cPort;
this->m_serverPort = sPort;
ms_dbg(4, "Transaction context created.");
@@ -320,7 +320,7 @@ int Transaction::processConnection(const char *client, int cPort,
m_variableRemoteHost.set(*m_clientIpAddress.get(), m_variableOffset);
m_variableUniqueID.set(m_id, m_variableOffset);
m_variableRemoteAddr.set(*m_clientIpAddress.get(), m_variableOffset);
m_variableServerAddr.set(m_serverIpAddress, m_variableOffset);
m_variableServerAddr.set(*m_serverIpAddress.get(), m_variableOffset);
m_variableServerPort.set(std::to_string(this->m_serverPort),
m_variableOffset);
m_variableRemotePort.set(std::to_string(this->m_clientPort),
@@ -470,9 +470,11 @@ int Transaction::processURI(const char *uri, const char *method,
if (pos != std::string::npos) {
m_uri_no_query_string_decoded = std::string(m_uri_decoded, 0, pos);
m_uri_no_query_string_decoded = std::unique_ptr<std::string>(
new std::string(m_uri_decoded, 0, pos));
} else {
m_uri_no_query_string_decoded = std::string(m_uri_decoded);
m_uri_no_query_string_decoded = std::unique_ptr<std::string>(
new std::string(m_uri_decoded));
}
@@ -1523,7 +1525,7 @@ std::string Transaction::toOldAuditLogFormat(int parts,
audit_log << " " << this->m_id.c_str();
audit_log << " " << this->m_clientIpAddress;
audit_log << " " << this->m_clientPort;
audit_log << " " << this->m_serverIpAddress;
audit_log << " " << m_serverIpAddress;
audit_log << " " << this->m_serverPort;
audit_log << std::endl;
@@ -1644,7 +1646,7 @@ std::string Transaction::toJSON(int parts) {
LOGFY_ADD("time_stamp", ts.c_str());
LOGFY_ADD("server_id", uniqueId.c_str());
LOGFY_ADD_NUM("client_port", m_clientPort);
LOGFY_ADD("host_ip", m_serverIpAddress.c_str());
LOGFY_ADD("host_ip", m_serverIpAddress->c_str());
LOGFY_ADD_NUM("host_port", m_serverPort);
LOGFY_ADD("unique_id", this->m_id.c_str());