diff --git a/apache2/apache2_config.c b/apache2/apache2_config.c index bfbcb834..bad5c5dc 100644 --- a/apache2/apache2_config.c +++ b/apache2/apache2_config.c @@ -755,6 +755,9 @@ static const char *add_rule(cmd_parms *cmd, directory_config *dcfg, int type, char *rid = NULL; msre_rule *rule = NULL; extern msc_engine *modsecurity; + int type_with_lua = 1; + int type_rule; + int rule_actionset; int offset = 0; #ifdef DEBUG_CONF @@ -787,25 +790,25 @@ static const char *add_rule(cmd_parms *cmd, directory_config *dcfg, int type, } /* Rules must have uniq ID */ - if ( + type_rule = (dcfg->tmp_chain_starter == NULL); #if defined(WITH_LUA) - type != RULE_TYPE_LUA && + type_rule = (type != RULE_TYPE_LUA && type_rule); #endif - (dcfg->tmp_chain_starter == NULL)) + if (type_rule) if(rule->actionset == NULL) return "ModSecurity: Rules must have at least id action"; if(rule->actionset != NULL && (dcfg->tmp_chain_starter == NULL)) { - if(rule->actionset->id == NOT_SET_P + rule_actionset = (rule->actionset->id == NOT_SET_P); #if defined(WITH_LUA) - && (type != RULE_TYPE_LUA) + rule_actionset = (rule_actionset && (type != RULE_TYPE_LUA)); #endif - ) - return "ModSecurity: No action id present within the rule"; + if (rule_actionset) + return "ModSecurity: No action id present within the rule"; #if defined(WITH_LUA) - if(type != RULE_TYPE_LUA) + type_with_lua = (type != RULE_TYPE_LUA); #endif - { + if (type_with_lua){ rid = apr_hash_get(dcfg->rule_id_htab, rule->actionset->id, APR_HASH_KEY_STRING); if(rid != NULL) { return "ModSecurity: Found another rule with the same id"; @@ -1666,7 +1669,7 @@ static const char *cmd_rule_perf_time(cmd_parms *cmd, void *_dcfg, } char *parser_conn_limits_operator(apr_pool_t *mp, const char *p2, - TreeRoot **whitelist, TreeRoot **suspicious_list, + TreeRoot **whitelist, TreeRoot **suspicious_list, const char *filename) { int res = 0; @@ -1753,7 +1756,7 @@ static const char *cmd_conn_read_state_limit(cmd_parms *cmd, void *_dcfg, if (param) return param; } - + conn_read_state_limit = limit; return NULL; diff --git a/apache2/mod_security2.c b/apache2/mod_security2.c index 519f2cc8..5404fd87 100644 --- a/apache2/mod_security2.c +++ b/apache2/mod_security2.c @@ -1086,6 +1086,7 @@ static void hook_error_log(const char *file, int line, int level, apr_status_t s { modsec_rec *msr = NULL; error_message_t *em = NULL; + int msr_ap_server; #if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2 if (info == NULL) return; @@ -1102,15 +1103,15 @@ static void hook_error_log(const char *file, int line, int level, apr_status_t s /* Create a context for requests we never had the chance to process */ #if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2 - if ((msr == NULL) + msr_ap_server = ((msr == NULL) && ((info->level & APLOG_LEVELMASK) < APLOG_DEBUG) - && apr_table_get(info->r->subprocess_env, "UNIQUE_ID")) + && apr_table_get(info->r->subprocess_env, "UNIQUE_ID")); #else - if ((msr == NULL) + msr_ap_server = ((msr == NULL) && ((level & APLOG_LEVELMASK) < APLOG_DEBUG) - && apr_table_get(r->subprocess_env, "UNIQUE_ID")) + && apr_table_get(r->subprocess_env, "UNIQUE_ID")); #endif - { + if (msr_ap_server) { #if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2 msr = create_tx_context((request_rec *)info->r); #else @@ -1484,7 +1485,7 @@ static int hook_connection_early(conn_rec *conn) conn_read_state_suspicious_list, client_ip, NULL, &error_msg) <= 0)) { if (conn_limits_filter_state == MODSEC_DETECTION_ONLY) - ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, "ModSecurity: Too many threads [%ld] of %ld allowed " \ "in READ state from %s - There is a suspission list " \ "but that IP is not part of it, access granted", diff --git a/standalone/config.c b/standalone/config.c index 1552c6fa..800d5b43 100644 --- a/standalone/config.c +++ b/standalone/config.c @@ -432,6 +432,7 @@ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, apr_file_t *file = NULL; apr_finfo_t finfo; apr_status_t status; + int exist_type; #ifdef DEBUG char buf[120]; #endif @@ -457,13 +458,13 @@ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, if (status != APR_SUCCESS) return status; - if (finfo.filetype != APR_REG && + exist_type = (finfo.filetype != APR_REG); #if defined(WIN32) || defined(OS2) || defined(NETWARE) - strcasecmp(apr_filepath_name_get(name), "nul") != 0) { + exist_type = (exist_type && strcasecmp(apr_filepath_name_get(name), "nul") != 0); #else - strcmp(name, "/dev/null") != 0) { + exist_type = (exist_type && strcmp(name, "/dev/null") != 0); #endif /* WIN32 || OS2 */ - ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + if (exist_type){ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "Access to file %s denied by server: not a regular file", name); apr_file_close(file); @@ -503,7 +504,7 @@ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, #else new_cfg->getch = cfg_getch; new_cfg->getstr = cfg_getstr; - new_cfg->close = cfg_close; + new_cfg->close = cfg_close; #endif new_cfg->line_number = 0; *ret_cfg = new_cfg;