diff options
author | Christoph Lipka <clipka@jp.adit-jv.com> | 2015-12-11 11:40:11 +0900 |
---|---|---|
committer | Gernot Wirschal <gernot.wirschal@bmw.de> | 2016-04-25 09:05:44 +0200 |
commit | 71ab66bb38783b6470844313d80b6dde6e514894 (patch) | |
tree | 436f3953e299b223bc1b1cfa8a2fa74f111a5125 /src | |
parent | 34a05874da76a971077471c37e88ca9cd2c4b5a0 (diff) | |
download | DLT-daemon-71ab66bb38783b6470844313d80b6dde6e514894.tar.gz |
Offline logstorage: Fix invalid filter configuration handling
- double free SIGSEGV caused by uninitialized free'd value in case
of uncomplete Logstorage filter configuration
- load configuratation returns error when the last configuration is
invalid, but previous configurations are valid which results in
memory leaks
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
Change-Id: I44103ed6b17e4b02eb35bdb575c234ff12bb5208
Diffstat (limited to 'src')
-rw-r--r-- | src/offlinelogstorage/dlt_offline_logstorage.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c index e6be6f9..8e1dbad 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage.c +++ b/src/offlinelogstorage/dlt_offline_logstorage.c @@ -901,6 +901,13 @@ void dlt_logstorage_filter_set_strategy(DltLogStorageConfigData *config, */ int dlt_logstorage_store_filters(DltLogStorage *handle, char *config_file_name) { + /* Read and store filters */ + int i = 0; + int j = 0; + int ret = -1; + /* we have to make sure that this function returns success as soon as one + * filter configuration is valid */ + int valid = -1; int is_filter_set = DLT_OFFLINE_LOGSTORAGE_FILTER_UNINIT; char *appid = NULL; char *ctxid = NULL; @@ -936,10 +943,6 @@ int dlt_logstorage_store_filters(DltLogStorage *handle, char *config_file_name) return -1; } - /* Read and store filters */ - int i = 0; - int j = 0; - int ret = -1; memset(&tmp_data, 0, sizeof(DltLogStorageConfigData)); for (i = 0; i < num_filters; i++) @@ -947,6 +950,7 @@ int dlt_logstorage_store_filters(DltLogStorage *handle, char *config_file_name) if (tmp_data.file_name != NULL) { free(tmp_data.file_name); + tmp_data.file_name = NULL; } if (tmp_data.ecuid != NULL) @@ -1040,6 +1044,11 @@ int dlt_logstorage_store_filters(DltLogStorage *handle, char *config_file_name) dlt_log(LOG_ERR, "dlt_logstorage_store_filters Error : Storing filter values failed\n"); break; } + else + { + /* we successfully stored one filter configuration */ + valid = 0; + } is_filter_set = DLT_OFFLINE_LOGSTORAGE_FILTER_UNINIT; } } @@ -1058,7 +1067,7 @@ int dlt_logstorage_store_filters(DltLogStorage *handle, char *config_file_name) dlt_config_file_release(config_file); - return ret; + return valid; } /** |