Skip to content
Open
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
6 changes: 5 additions & 1 deletion 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 @@ -1664,7 +1664,11 @@

/* Add the MODSEC_a.b define */
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Add the MODSEC_a.b define" but this block now adds multiple defines (including feature/compile-mode defines). Update the comment (or split it) so it accurately describes what is being added.

Suggested change
/* Add the MODSEC_a.b define */
/* Add version, feature, and compile-mode ModSecurity defines. */

Copilot uses AI. Check for mistakes.
*(char **)apr_array_push(ap_server_config_defines) = apr_psprintf(mp, "MODSEC_%s.%s", MODSEC_VERSION_MAJOR, MODSEC_VERSION_MINOR);

*(char **)apr_array_push(ap_server_config_defines) = apr_pstrdup(mp, "MODSEC_AnalyseMultipartHeaders");
*(char **)apr_array_push(ap_server_config_defines) = apr_pstrdup(mp, "MODSEC_ARGS_COMBINED_SIZE_NONAME");
#ifndef WITH_PCRE
*(char **)apr_array_push(ap_server_config_defines) = apr_pstrdup(mp, "MODSEC_PCRE2");
#endif
#if (!defined(NO_MODSEC_API))
/* Export optional functions. */
APR_REGISTER_OPTIONAL_FN(modsec_register_tfn);
Expand Down
2 changes: 2 additions & 0 deletions apache2/msc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,8 @@ char *construct_single_var(modsec_rec *msr, char *name) {
msre_var *vx = NULL;
char *my_error_msg = NULL;

if (msr->msc_rule_mptmp == NULL) return NULL;
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

construct_single_var now returns NULL whenever msr->msc_rule_mptmp is NULL. msr->msc_rule_mptmp is initialized to NULL at transaction creation (apache2/mod_security2.c:582) and is only created during rule processing (apache2/re.c:3362-3368), so requests that reach logging without any rule execution will stop producing log variables (instead of being computable from msr->mp). Consider lazily creating msc_rule_mptmp here (e.g., apr_pool_create with parent msr->mp) or otherwise providing a safe fallback pool rather than returning NULL.

Copilot uses AI. Check for mistakes.

/* Extract variable name and its parameter from the script. */
varname = apr_pstrdup(msr->mp, name);
if (varname == NULL) return NULL;
Expand Down
Loading