Skip to content

V2/cppcheck 0702 clean#3595

Closed
umprayz wants to merge 8 commits into
owasp-modsecurity:v2/masterfrom
umprayz:v2/cppcheck_0702_clean
Closed

V2/cppcheck 0702 clean#3595
umprayz wants to merge 8 commits into
owasp-modsecurity:v2/masterfrom
umprayz:v2/cppcheck_0702_clean

Conversation

@umprayz

@umprayz umprayz commented Jul 8, 2026

Copy link
Copy Markdown

what

  • This pull request fixes the cppcheck warnings in all .c, .cpp and .h files within iis/ ext/ and mlogc/ directories.
  • These were added to the cppcheck command in the Makefile.am.

why

  • The changes did not changed any logic, and were based on the output of the cppcheck command.
  • Now, said command produces zero warnings in these three directories.
  • One other change was made in the api.c and api.h files in the standalone/ directory, in order to resolve a warning in these two function: modsecSetWriteBody() and modsecSetWriteResponse(). The mymodule.cpp uses them in its WriteResponseCallback() and WriteBodyCallback() functions.

references

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request aims to make the repository’s cppcheck target run clean by applying const-correctness and minor safety/cleanup edits across standalone/, mlogc/, iis/, and ext/, and by expanding the cppcheck Makefile target’s scan scope.

Changes:

  • Expand the cppcheck Makefile target to scan additional directories.
  • Adjust callback and helper signatures (mostly adding const) to address cppcheck warnings.
  • Add/adjust a few local safety and initialization patterns to quiet analyzer findings (e.g., malloc() NULL handling, unused/uninit suppressions).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
standalone/api.h Updates write callback setter prototypes to take const char *buf.
standalone/api.c Updates write callback setters to take const char *buf (but currently leaves internal function-pointer types inconsistent).
mlogc/mlogc.c Const-correctness tweaks, local variable scoping, and malloc-null handling in queue entry creation.
Makefile.am Extends the cppcheck target to include more directories.
iis/mymodule.cpp Const-correctness and initialization tweaks; updates IIS write callbacks to accept const char *buf.
iis/moduleconfig.h Moves m_Config and adds a cppcheck suppression comment.
iis/moduleconfig.cpp Replaces C-style casts with reinterpret_cast.
iis/main.cpp Comments out a request-notification priority call (behavior change).
ext/mod_var_remote_addr_port.c Makes msre_var parameters const in generator helpers.
ext/mod_op_strstr.c Adds const qualifiers to operator execution params and refines Boyer–Moore implementation locals.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mlogc/mlogc.c
Comment on lines 399 to +404
entry = (entry_t *)malloc(sizeof(entry_t));
entry->id = 0;
entry->line = strdup(data);
entry->line_size = strlen(entry->line);
if(entry != NULL){
entry->id = 0;
entry->line = strdup(data);
entry->line_size = strlen(entry->line);
}
Comment thread standalone/api.c
Comment on lines +687 to 693
void modsecSetWriteBody(apr_status_t (*func)(request_rec *r, const char *buf, unsigned int length)) {
modsecWriteBody = func;
}

void modsecSetWriteResponse(apr_status_t (*func)(request_rec *r, char *buf, unsigned int length)) {
void modsecSetWriteResponse(apr_status_t (*func)(request_rec *r, const char *buf, unsigned int length)) {
modsecWriteResponse = func;
}
Comment thread iis/main.cpp
Comment thread Makefile.am Outdated
Comment on lines +58 to +63
standalone/ \
mlogc/ \
iis/ \
ext/ \
build/ \
doc/
Comment thread iis/mymodule.cpp
Comment on lines 460 to 462
USHORT ctcch = 0;
char *ct = (char *)pHttpResponse->GetHeader(HttpHeaderContentType, &ctcch);
const char *ct = (char *)pHttpResponse->GetHeader(HttpHeaderContentType, &ctcch);
char *ctz = ZeroTerminate(ct, ctcch, r->pool);
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@umprayz umprayz closed this Jul 9, 2026
@umprayz umprayz deleted the v2/cppcheck_0702_clean branch July 9, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants