Skip to content

Commit a157ac2

Browse files
author
Felipe Zimmerle
committed
Fix compilation issue on "pedantic" compilers
1 parent eef2c03 commit a157ac2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

apache2/msc_logging.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,13 @@ static void write_rule_json(modsec_rec *msr, const msre_rule *rule, yajl_gen g)
571571
yajl_kv_string(g, "version", log_escape(msr->mp, rule->actionset->version));
572572
}
573573
if (rule->actionset->logdata) {
574+
char *logdata = NULL;
574575
msc_string *var = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
575576
var->value = (char *)rule->actionset->logdata;
576577
var->value_len = strlen(rule->actionset->logdata);
577578
expand_macros(msr, var, NULL, msr->mp);
578579

579-
char *logdata = apr_pstrdup(msr->mp, log_escape_hex(msr->mp, (unsigned char *)var->value, var->value_len));
580+
logdata = apr_pstrdup(msr->mp, log_escape_hex(msr->mp, (unsigned char *)var->value, var->value_len));
580581

581582
// if it is > 512 bytes, then truncate at 512 with ellipsis.
582583
if (strlen(logdata) > 515) {
@@ -611,14 +612,15 @@ static void write_rule_json(modsec_rec *msr, const msre_rule *rule, yajl_gen g)
611612
for (k = 0; k < tarr->nelts; k++) {
612613
msre_action *action = (msre_action *)telts[k].val;
613614
if (strcmp(telts[k].key, "tag") == 0) {
615+
msc_string *var = NULL;
614616
if (been_opened == 0) {
615617
yajl_string(g, "tags");
616618
yajl_gen_array_open(g);
617619
been_opened = 1;
618620
}
619621

620622
// expand variables in the tag
621-
msc_string *var = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
623+
var = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
622624
var->value = (char *)action->param;
623625
var->value_len = strlen(action->param);
624626
expand_macros(msr, var, NULL, msr->mp);
@@ -676,6 +678,9 @@ void sec_audit_logger_json(modsec_rec *msr) {
676678
int arg_min, arg_max, sanitize_matched;
677679
yajl_gen g;
678680
int been_opened = 0; // helper flag for conditionally opening maps
681+
const unsigned char *final_buf;
682+
size_t len;
683+
679684

680685
/* Return silently if we don't have a request line. This
681686
* means we will not be logging request timeouts.
@@ -1437,8 +1442,6 @@ void sec_audit_logger_json(modsec_rec *msr) {
14371442
/* finished building JSON */
14381443
yajl_gen_map_close(g); // box it up!
14391444

1440-
const unsigned char *final_buf;
1441-
size_t len;
14421445
yajl_gen_get_buf(g, &final_buf, &len);
14431446
sec_auditlog_write(msr, final_buf, len);
14441447

0 commit comments

Comments
 (0)