From 62a6f228f81ad89e4536af8f6b22871709f65720 Mon Sep 17 00:00:00 2001 From: Jiri Kukacka Date: Mon, 9 Dec 2013 18:58:21 +0100 Subject: [PATCH] Fixes for Parfait errors - mostly unhandled NULL pointer dereference and data type mismatch --- apache2/mod_security2.c | 2 +- apache2/re.c | 4 ++++ apache2/re_actions.c | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apache2/mod_security2.c b/apache2/mod_security2.c index 78e1e75c..892242a6 100644 --- a/apache2/mod_security2.c +++ b/apache2/mod_security2.c @@ -1038,7 +1038,7 @@ static void hook_error_log(const char *file, int line, int level, apr_status_t s #else msr = create_tx_context((request_rec *)r); #endif - if (msr->txcfg->debuglog_level >= 9) { + if (msr != NULL && msr->txcfg->debuglog_level >= 9) { if (msr == NULL) { msr_log(msr, 9, "Failed to create context after request failure."); } diff --git a/apache2/re.c b/apache2/re.c index 2d6e2465..d06c7583 100644 --- a/apache2/re.c +++ b/apache2/re.c @@ -1340,6 +1340,10 @@ msre_actionset *msre_actionset_create_default(msre_engine *engine) { * Sets the default values for the hard-coded actionset configuration. */ void msre_actionset_set_defaults(msre_actionset *actionset) { + + if (actionset == NULL) { + return; + } /* Metadata */ if (actionset->id == NOT_SET_P) actionset->id = NULL; if (actionset->rev == NOT_SET_P) actionset->rev = NULL; diff --git a/apache2/re_actions.c b/apache2/re_actions.c index 6a5fbac6..fbd38f5c 100644 --- a/apache2/re_actions.c +++ b/apache2/re_actions.c @@ -1470,7 +1470,7 @@ static apr_status_t msre_action_setenv_execute(modsec_rec *msr, apr_pool_t *mptm env_name = log_escape_nq_ex(msr->mp, env->value, env->value_len); /* Execute the requested action. */ - if (env_name[0] == '!') { + if (env_name != NULL && env_name[0] == '!') { /* Delete */ apr_table_unset(msr->r->subprocess_env, env_name + 1); @@ -1532,7 +1532,7 @@ apr_status_t msre_action_setvar_execute(modsec_rec *msr, apr_pool_t *mptmp, var_name = log_escape_nq_ex(msr->mp, var->value, var->value_len); /* Handle the exclamation mark. */ - if (var_name[0] == '!') { + if (var_name != NULL && var_name[0] == '!') { var_name = var_name + 1; is_negated = 1; }