From f5095cf33d806de1061652fa79f8ddb215c46ac4 Mon Sep 17 00:00:00 2001 From: kundatipradeep <35292742+kundatipradeep@users.noreply.github.com> Date: Mon, 22 Jan 2018 14:02:08 +0530 Subject: Fix SEGV dlt_offline_trace.c (#32) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post enabling and updating “OfflineTraceDirectory” variable default path in dlt.conf file, dlt-daemon resulted in crash with Segmentation fault(SIGSEGV) due to Invalid OfflineTraceDirectory path. dlt_offline_trace-patch-1 contains an update which verifies “existence of offline trace directory” and its “accessibility issues”. It returns -1 on failure conditions and indicates user with appropriate information instead resulting in APPCRASH. --- src/shared/dlt_offline_trace.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c index c155455..32b5253 100644 --- a/src/shared/dlt_offline_trace.c +++ b/src/shared/dlt_offline_trace.c @@ -62,8 +62,10 @@ #include #include #include +#include #include +#include "dlt_common.h" unsigned int dlt_offline_trace_storage_dir_info(char *path, char *file_name, char *newest, char *oldest) { @@ -339,6 +341,22 @@ int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) { DltReturnValue dlt_offline_trace_check_size(DltOfflineTrace *trace) { + struct stat status; + + /* check for existence of offline trace directory */ + if (stat(trace->directory, &status) == -1) + { + dlt_vlog(LOG_ERR, "Offline trace directory: %s doesn't exist \n", trace->directory); + return DLT_RETURN_ERROR; + } + + /* check for accesibilty of offline trace directory */ + else if(access(trace->directory, W_OK) != 0) + { + dlt_vlog(LOG_ERR, "Offline trace directory: %s doesn't have the write access \n", trace->directory); + return DLT_RETURN_ERROR; + } + /* check size of complete offline trace */ while((int)dlt_offline_trace_get_total_size(trace) > (trace->maxSize-trace->fileSize)) { -- cgit v1.2.1