diff options
author | kundatipradeep <35292742+kundatipradeep@users.noreply.github.com> | 2018-01-22 14:02:08 +0530 |
---|---|---|
committer | Christoph Lipka <clipka@users.noreply.github.com> | 2018-01-22 09:32:08 +0100 |
commit | f5095cf33d806de1061652fa79f8ddb215c46ac4 (patch) | |
tree | 4d2fb3d07aefecdf5453618d6d9ac069fb2f6cb0 /src | |
parent | ebf9882460d3a72b57cad69e9ec15e79f6b7bd6c (diff) | |
download | DLT-daemon-f5095cf33d806de1061652fa79f8ddb215c46ac4.tar.gz |
Fix SEGV dlt_offline_trace.c (#32)
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/dlt_offline_trace.c | 18 |
1 files changed, 18 insertions, 0 deletions
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 <fcntl.h> #include <unistd.h> #include <dirent.h> +#include <syslog.h> #include <dlt_offline_trace.h> +#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)) { |