Skip to content

Commit 41fd21b

Browse files
authored
Merge pull request owasp-modsecurity#3298 from airween/v3/sethostnamefix
Fix m_requestHostName variable behavior
2 parents 4a72000 + d422b36 commit 41fd21b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/transaction.cc

+3-1
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ void perform_unit_test(const ModSecurityTest<RegressionTest> &test,
269269

270270
auto modsec_transaction = context.create_transaction();
271271

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

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

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

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

0 commit comments

Comments
 (0)