Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apache2/mod_security2.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
msc_string *var = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));

var->value = (char *)actionset->intercept_pause;
var->value_len = strlen(actionset->intercept_pause);

Check warning on line 199 in apache2/mod_security2.c

View workflow job for this annotation

GitHub Actions / build (x64, Release)

'=': conversion from 'size_t' to 'unsigned int', possible loss of data [D:\a\ModSecurity\ModSecurity\iis\build\modsecurityiis.vcxproj]

Check warning on line 199 in apache2/mod_security2.c

View workflow job for this annotation

GitHub Actions / build (x64, RelWithDebInfo)

'=': conversion from 'size_t' to 'unsigned int', possible loss of data [D:\a\ModSecurity\ModSecurity\iis\build\modsecurityiis.vcxproj]
expand_macros(msr, var, NULL, msr->mp);

pause = atoi(var->value);
Expand Down Expand Up @@ -343,7 +343,7 @@
msc_string *var = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));

var->value = (char *)actionset->intercept_uri;
var->value_len = strlen(actionset->intercept_uri);

Check warning on line 346 in apache2/mod_security2.c

View workflow job for this annotation

GitHub Actions / build (x64, Release)

'=': conversion from 'size_t' to 'unsigned int', possible loss of data [D:\a\ModSecurity\ModSecurity\iis\build\modsecurityiis.vcxproj]

Check warning on line 346 in apache2/mod_security2.c

View workflow job for this annotation

GitHub Actions / build (x64, RelWithDebInfo)

'=': conversion from 'size_t' to 'unsigned int', possible loss of data [D:\a\ModSecurity\ModSecurity\iis\build\modsecurityiis.vcxproj]
expand_macros(msr, var, NULL, msr->mp);

apr_table_setn(msr->r->headers_out, "Location", var->value);
Expand Down Expand Up @@ -1217,7 +1217,7 @@
}
}

limit = limit - strlen(str2) - 5;

Check warning on line 1220 in apache2/mod_security2.c

View workflow job for this annotation

GitHub Actions / build (x64, Release)

'=': conversion from 'size_t' to 'int', possible loss of data [D:\a\ModSecurity\ModSecurity\iis\build\modsecurityiis.vcxproj]

Check warning on line 1220 in apache2/mod_security2.c

View workflow job for this annotation

GitHub Actions / build (x64, RelWithDebInfo)

'=': conversion from 'size_t' to 'int', possible loss of data [D:\a\ModSecurity\ModSecurity\iis\build\modsecurityiis.vcxproj]
if (limit <= 0) {
msr_log(msr, 1, "Audit Log: Atomic PIPE write buffer too small: %d", PIPE_BUF);
return;
Expand Down Expand Up @@ -1276,6 +1276,21 @@
arr = apr_table_elts(r->headers_out);
}

#if defined(VERSION_IIS)
/* The IIS connector never copies the response status into the
* request_rec; r->status is only set in OnSendResponse. A request
* that was superseded by an internal redirect (e.g. the IIS default
* document rewrite of "/" to "/iisstart.htm") never reaches
* OnSendResponse, so its r->status stays 0 and the audit log F part
* would record a bogus "500 Internal Server Error"
* (ap_get_status_line(0)). Skip audit logging for such transactions
* unless they were actually intercepted.
*/
if (r->status == 0 && msr->was_intercepted == 0) {
return DECLINED;
}
#endif

msr->r = r;
msr->response_status = r->status;
msr->status_line = ((r->status_line != NULL)
Expand Down
16 changes: 16 additions & 0 deletions iis/mymodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,22 @@ CMyHttpModule::OnSendResponse(
pHttpResponse = pHttpContext->GetResponse();
pRawHttpResponse = pHttpResponse->GetRawHttpResponse();

// here we must transfer response status
// otherwise r->status stays 0 and the audit log records a
// bogus "500 Internal Server Error" (ap_get_status_line(0))
// for every transaction
//
if(pRawHttpResponse->StatusCode > 0)
{
r->status = pRawHttpResponse->StatusCode;

if(pRawHttpResponse->pReason != NULL && pRawHttpResponse->ReasonLength > 0)
{
r->status_line = apr_psprintf(r->pool, "%d %s", r->status,
ZeroTerminate(pRawHttpResponse->pReason, pRawHttpResponse->ReasonLength, r->pool));
}
}

// here we must add handling of chunked response
// apparently IIS 7 calls this handler once per chunk
// see: http://stackoverflow.com/questions/4385249/how-to-buffer-and-process-chunked-data-before-sending-headers-in-iis7-native-mod
Expand Down
Loading