Greetings, here is a first try to participate on this awesome project.
Please review and send your comments bye, Torsten
>From 7d03490431e7fcb38ec1f9cdf127da5b48fed11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Pf=C3=BCller?= <[email protected]> Date: Mon, 26 Mar 2012 17:00:11 +0200 Subject: [PATCH] fix some memory leaks and use-after-free --- plugins/logger/logger.c | 15 ++++++++++++--- src/mk_config.c | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/logger/logger.c b/plugins/logger/logger.c index ebb51c2..6729cd6 100644 --- a/plugins/logger/logger.c +++ b/plugins/logger/logger.c @@ -234,6 +234,7 @@ void *mk_logger_worker_init(void *args) int mk_logger_read_config(char *path) { int timeout; + char *logfilename = NULL; unsigned long len; char *default_file = NULL; struct mk_config *conf; @@ -256,13 +257,21 @@ int mk_logger_read_config(char *path) PLUGIN_TRACE("FlushTimeout %i seconds", mk_logger_timeout); /* MasterLog */ - mk_logger_master_path = mk_api->config_section_getval(section, - "MasterLog", - MK_CONFIG_VAL_STR); + logfilename = mk_api->config_section_getval(section, + "MasterLog", + MK_CONFIG_VAL_STR); + if (logfilename == NULL) { + mk_err("MasterLog does not have a proper value"); + exit(EXIT_FAILURE); + } + + mk_logger_master_path = mk_api->str_dup(logfilename); PLUGIN_TRACE("MasterLog '%s'", mk_logger_master_path); } mk_api->mem_free(default_file); + mk_api->config_free(conf); + mk_api->mem_free(conf); return 0; } diff --git a/src/mk_config.c b/src/mk_config.c index e47f5c7..b502ac9 100644 --- a/src/mk_config.c +++ b/src/mk_config.c @@ -200,6 +200,7 @@ struct mk_config *mk_config_create(const char *path) if (end > 0) { section = mk_string_copy_substr(buf, 1, end); mk_config_section_add(conf, section); + mk_mem_free(section); continue; } else { @@ -271,6 +272,7 @@ struct mk_config *mk_config_create(const char *path) } fflush(stdout); */ + if (indent) mk_mem_free(indent); fclose(f); return conf; @@ -295,6 +297,7 @@ void mk_config_free(struct mk_config *conf) mk_mem_free(section); if (section == conf->section) { + conf->section = NULL; return; } prev->next = NULL; @@ -316,6 +319,7 @@ void mk_config_free_entries(struct mk_config_section *section) /* Free memory assigned */ mk_mem_free(target->key); mk_mem_free(target->val); + mk_mem_free(target); if (target == section->entry) { section->entry = NULL; -- 1.7.6.1
_______________________________________________ Monkey mailing list [email protected] http://lists.monkey-project.com/listinfo/monkey
