Skip to content

Fixed some memory leaks at analysisd #862

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

Merged
merged 1 commit into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 10 additions & 8 deletions src/analysisd/decoders/decode-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ static int os_setdecoderids(const char *p_name)
nnode->id = p_id;

/* Set parent name */
nnode->name = tmp_name;
free(nnode->name);
nnode->name = strdup(tmp_name);
}

/* Id cannot be 0 */
Expand Down Expand Up @@ -203,12 +204,14 @@ int ReadDecodeXML(const char *file)
}

/* Zero NULL_decoder */
os_calloc(1, sizeof(OSDecoderInfo), NULL_Decoder_tmp);
NULL_Decoder_tmp->id = 0;
NULL_Decoder_tmp->type = SYSLOG;
NULL_Decoder_tmp->name = NULL;
NULL_Decoder_tmp->fts = 0;
NULL_Decoder = NULL_Decoder_tmp;
if (!NULL_Decoder) {
os_calloc(1, sizeof(OSDecoderInfo), NULL_Decoder_tmp);
NULL_Decoder_tmp->id = 0;
NULL_Decoder_tmp->type = SYSLOG;
NULL_Decoder_tmp->name = NULL;
NULL_Decoder_tmp->fts = 0;
NULL_Decoder = NULL_Decoder_tmp;
}

i = 0;
while (node[i]) {
Expand Down Expand Up @@ -751,4 +754,3 @@ char *_loadmemory(char *at, char *str)
}
return (NULL);
}

2 changes: 1 addition & 1 deletion src/analysisd/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ int Rules_OP_ReadRules(const char *rulefile)
free(if_matched_regex);
if_matched_regex = NULL;
}
OS_ClearNode(rule_opt);
} /* end of elements block */

/* Assign an active response to the rule */
Expand Down Expand Up @@ -1761,4 +1762,3 @@ static int doesRuleExist(int sid, RuleNode *r_node)

return (0);
}

3 changes: 2 additions & 1 deletion src/config/rules-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ int Read_Rules(XML_NODE node, void *configp, __attribute__((unused)) void *mailp
}
}

OSRegex_FreePattern(&regex);
closedir(dfd);
/* Sort just then newly added items */
qsort(Config->decoders + start_point , decoders_size - start_point - 1, sizeof(char *), cmpr);
Expand Down Expand Up @@ -242,6 +243,7 @@ int Read_Rules(XML_NODE node, void *configp, __attribute__((unused)) void *mailp
}
}

OSRegex_FreePattern(&regex);
closedir(dfd);
/* Sort just then newly added items */
qsort(Config->includes + start_point , rules_size - start_point - 1, sizeof(char *), cmpr);
Expand All @@ -255,4 +257,3 @@ int Read_Rules(XML_NODE node, void *configp, __attribute__((unused)) void *mailp
}
return (0);
}

2 changes: 1 addition & 1 deletion src/shared/store_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ int OSStore_Put(OSStore *list, const char *key, void *data)
if ((chk_rc = strcmp(list->cur_node->key, key)) >= 0) {
/* Duplicate entry */
if (chk_rc == 0) {
free(newnode->key);
free(newnode);
return (1);
}
Expand Down Expand Up @@ -380,4 +381,3 @@ int OSStore_Put(OSStore *list, const char *key, void *data)

return (1);
}