Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ cppcheck:
--inconclusive \
--template="warning: {file},{line},{severity},{id},{message}" \
--error-exitcode=1 \
standalone/
standalone/ \
mlogc/ \
iis/ \
ext/

check-static: cppcheck

Expand Down
10 changes: 4 additions & 6 deletions ext/mod_op_strstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static int op_strstr_init(msre_rule *rule, char **error_msg) {
/**
* Operator execution entry point.
*/
static int op_strstr_exec(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg) {
static int op_strstr_exec(modsec_rec const *msr, msre_rule const *rule, msre_var const *var, char **error_msg) {
/* Here we need to inspect the contents of the supplied variable. */

/* In a general case it is possible for the value
Expand Down Expand Up @@ -169,14 +169,12 @@ static void initBoyerMooreHorspool(const char *pattern, int patlength,
}

static int BoyerMooreHorspool(const char *pattern, int patlength,
const char *text, int textlen, int *bm_badcharacter_array)
const char *text, int textlen, int const *bm_badcharacter_array)
Comment thread
umprayz marked this conversation as resolved.
{
int j;
char c;
int j = 0;

j = 0;
while (j <= textlen - patlength) {
c = text[j + patlength - 1];
char c = text[j + patlength - 1];
if (pattern[patlength - 1] == c && memcmp(pattern, text + j, patlength - 1) == 0) {
return j;
}
Expand Down
6 changes: 3 additions & 3 deletions ext/mod_var_remote_addr_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* Generates a variable from a string and a length.
*/
static int var_simple_generate_ex(msre_var *var, apr_table_t *vartab, apr_pool_t *mptmp,
static int var_simple_generate_ex(msre_var const *var, apr_table_t *vartab, apr_pool_t *mptmp,
const char *value, int value_len)
{
msre_var *rvar = NULL;
Expand All @@ -45,7 +45,7 @@ static int var_simple_generate_ex(msre_var *var, apr_table_t *vartab, apr_pool_t
/**
* Generates a variable from a NULL-terminated string.
*/
static int var_simple_generate(msre_var *var, apr_table_t *vartab, apr_pool_t *mptmp,
static int var_simple_generate(msre_var const *var, apr_table_t *vartab, apr_pool_t *mptmp,
const char *value)
{
if (value == NULL) return 0;
Expand All @@ -58,7 +58,7 @@ static int var_simple_generate(msre_var *var, apr_table_t *vartab, apr_pool_t *m
/**
* Create a silly variable with value = a.b.c.d:port
*/
static int var_remote_addr_port_generate(modsec_rec *msr, msre_var *var, msre_rule *rule,
static int var_remote_addr_port_generate(modsec_rec *msr, msre_var const *var, msre_rule *rule,
apr_table_t *vartab, apr_pool_t *mptmp)
{
const char *value = apr_psprintf(mptmp, "%s:%d", msr->remote_addr, msr->remote_port);
Expand Down
3 changes: 2 additions & 1 deletion iis/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ RegisterModule(
}

hr = pModuleInfo->SetPriorityForRequestNotification(RQ_BEGIN_REQUEST, PRIORITY_ALIAS_FIRST);
hr = pModuleInfo->SetPriorityForRequestNotification(RQ_SEND_RESPONSE, PRIORITY_ALIAS_LAST); // reverted!
hr = pModuleInfo->SetPriorityForRequestNotification(RQ_SEND_RESPONSE, PRIORITY_ALIAS_LAST); // cppcheck-suppress redundantAssignment
// reverted!
//hr = pModuleInfo2->SetPriorityForPostRequestNotification(RQ_END_REQUEST, PRIORITY_ALIAS_LAST);

pFactory = NULL;
Expand Down
16 changes: 12 additions & 4 deletions iis/moduleconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ MODSECURITY_STORED_CONTEXT::Initialize(
// If there is a config failure, we cannot continue execution:
if ( pPropertyException != NULL )
{

ppException = ( IAppHostConfigException** ) &pPropertyException;

// If there is a config failure, we cannot continue execution
// To avoid using reinterpret_cast, we will use static_cast to
// convert the IAppHostPropertyException to IAppHostConfigException
// An additional variable was created to hold the static_cast result
// and then assigned to ppException therefore avoiding double referencing.
auto pConfigExc = static_cast<IAppHostConfigException*>(pPropertyException);
ppException = &pConfigExc;
goto Failure;
Comment thread
umprayz marked this conversation as resolved.
Outdated
}

Expand All @@ -107,7 +113,9 @@ MODSECURITY_STORED_CONTEXT::Initialize(
if ( pPropertyException != NULL )
{

ppException = ( IAppHostConfigException** ) &pPropertyException;
// See prevoius comment regarding static_cast and ppException assignment
Comment thread
umprayz marked this conversation as resolved.
Outdated
auto pConfigExc = static_cast<IAppHostConfigException*>(pPropertyException);
ppException = &pConfigExc;
goto Failure;
Comment thread
umprayz marked this conversation as resolved.
Outdated
}

Expand Down Expand Up @@ -466,7 +474,7 @@ MODSECURITY_STORED_CONTEXT::~MODSECURITY_STORED_CONTEXT()
MODSECURITY_STORED_CONTEXT::MODSECURITY_STORED_CONTEXT():
m_bIsEnabled ( FALSE ),
m_pszPath( NULL ),
m_Config( NULL )
m_Config( NULL )
{
}

Expand Down
3 changes: 1 addition & 2 deletions iis/moduleconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern PVOID g_pModuleContext;
class MODSECURITY_STORED_CONTEXT : public IHttpStoredContext
{
public:
void* m_Config; // cppcheck-suppress initializerList
Comment thread
umprayz marked this conversation as resolved.
MODSECURITY_STORED_CONTEXT();
~MODSECURITY_STORED_CONTEXT();

Expand Down Expand Up @@ -67,8 +68,6 @@ class MODSECURITY_STORED_CONTEXT : public IHttpStoredContext
CHAR** ppszDestination,
USHORT* pdwLengthDestination );

void* m_Config;

private:
HRESULT
GetBooleanPropertyValue(
Expand Down
Loading
Loading