Skip to content
Open
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions src/utils/acmp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,18 @@
child->pattern = (char *)"";
child->letter = letter;
child->depth = i;
child->text = (char *)calloc(1, strlen(pattern) + 2);
child->text = (char *)calloc(1, length + 2);

Check failure on line 390 in src/utils/acmp.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this use of "calloc".

See more on https://sonarcloud.io/project/issues?id=owasp-modsecurity_ModSecurity&issues=AZ2Cs4j1K0fgB4uOo37q&open=AZ2Cs4j1K0fgB4uOo37q&pullRequest=3544
Comment thread
airween marked this conversation as resolved.
Outdated
/* ENH: Check alloc succeded */
for (j = 0; j <= i; j++) child->text[j] = pattern[j];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for (j = 0; j <= i; j++) child->text[j] = pattern[j];
for (j = 0; j <= i; j++) {
child->text[j] = pattern[j];
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not use memcpy here as well?

}
if (i == length - 1) {
if (child->is_last == 0) {
parser->dict_count++;
child->is_last = 1;
child->pattern = (char *)calloc(1, strlen(pattern) + 2);
child->pattern = (char *)calloc(1, length + 2);

Check failure on line 398 in src/utils/acmp.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this use of "calloc".

See more on https://sonarcloud.io/project/issues?id=owasp-modsecurity_ModSecurity&issues=AZ2Cs4j1K0fgB4uOo37r&open=AZ2Cs4j1K0fgB4uOo37r&pullRequest=3544
Comment thread
airween marked this conversation as resolved.
Outdated
/* ENH: Check alloc succeded */
strcpy(child->pattern, pattern);
memcpy(child->pattern, pattern, length);
child->pattern[length] = '\0';
}
child->callback = callback;
child->callback_data = data;
Expand Down
Loading