Skip to content

Commit d422b36

Browse files
committed
Add condition before set hostname; move setRequestHostName() before processConnection()
1 parent ec506da commit d422b36

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/transaction.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ int Transaction::processConnection(const char *client, int cPort,
227227
const char *server, int sPort) {
228228
m_clientIpAddress = client;
229229
m_serverIpAddress = server;
230-
m_requestHostName = server;
230+
if (m_requestHostName.empty() == true) {
231+
m_requestHostName = server;
232+
}
231233
this->m_clientPort = cPort;
232234
this->m_serverPort = sPort;
233235
ms_dbg(4, "Transaction context created.");

test/regression/regression.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,15 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
268268

269269
auto modsec_transaction = context.create_transaction();
270270

271+
if (t->hostname != "") {
272+
modsec_transaction.setRequestHostName(t->hostname);
273+
}
274+
271275
clearAuditLog(modsec_transaction.m_rules->m_auditLog->m_path1);
272276

273277
modsec_transaction.processConnection(t->clientIp.c_str(),
274278
t->clientPort, t->serverIp.c_str(), t->serverPort);
275279

276-
if (t->hostname != "") {
277-
modsec_transaction.setRequestHostName(t->hostname);
278-
}
279-
280280
actions(&r, &modsec_transaction, &context.m_server_log);
281281

282282
modsec_transaction.processURI(t->uri.c_str(), t->method.c_str(),

0 commit comments

Comments
 (0)