-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix repeated wodle modules #1128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/config/wmodules-command.c
Outdated
command_tag_length = strlen(WM_COMMAND_CONTEXT.name) + 2; | ||
command_tag = malloc(sizeof(char) * command_tag_length); | ||
snprintf(command_tag, command_tag_length, "%s", WM_COMMAND_CONTEXT.name); | ||
os_strdup(command_tag, nodes[i]->content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os_strdup
sets from left to right. In this case, it would be overwriting the content of the XML structure and producing a memory leak.
Did you mean...?
os_strdup(command_tag, command->tag);
src/config/wmodules-command.c
Outdated
snprintf(command_tag, command_tag_length, "%s:%s", WM_COMMAND_CONTEXT.name, command->tag); | ||
} | ||
|
||
os_strdup(command_tag, module->tag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence duplicates the string at command_tag
, but this variable is never freed. This produces a memory leak.
src/wazuh_modules/wmodules.c
Outdated
if (i->context->name == j->context->name) { | ||
mdebug1("Deleting repeated module '%s'.", j->context->name); | ||
if(i->tag && j->tag){ | ||
if(!strcmp(i->tag,"command") || !strcmp(j->tag,"command")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be mandatory at this point. We should warn about it in the configuration reader.
51b7651
to
a0766e4
Compare
9a7f122
to
97f1463
Compare
97f1463
to
cae382b
Compare
GJ @cristgl !! |
This PR fixes the issue #1057.
Added a new field to wodle modules named
tag
, consisting of the 'command' word plus the command tag in case of the Command wodle, in other case, it shows the name of the module.