From be9c3bf964295883ff086dfb8c2ece38f833b355 Mon Sep 17 00:00:00 2001 From: Simon Brandner Date: Thu, 6 Dec 2012 10:18:12 +0100 Subject: appended null termination to version string adding closure of socket in syslog_thread and read_socket fixed missing free of filepath in compressed file transfer fixed missing closedir in added in send_one error case fixed missing fclose of src_file in ferror case dlt-daemon.c fixed missing fclose in ferror case dlt_common.c using snprintf for filename instead sprintf in dlt_file_open modified some magix numbers - replaced by limits.h values. added strncpy instead strcpy to make cp more safe. split up a function to avoid coverity complaint when computing size of a write buffer length dlt_daemon_common: added strncpy instead strcpy to make cp more safe. Fixes some more Coverity issues in dlt-daemon.c dlt_user.c dlt_common.c and dlt_offline_trace.c. Conflicts: src/daemon/dlt-daemon.c src/lib/dlt_user.c Signed-off-by: Alexander Wenzel --- src/daemon/dlt_daemon_common.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/daemon/dlt_daemon_common.c') diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index 7bbce7b..2f0e73a 100644 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -125,6 +125,7 @@ int dlt_daemon_init(DltDaemon *daemon,const char *runtime_directory, int verbose return -1; } + int append_length = 0; daemon->num_contexts = 0; daemon->contexts = 0; @@ -141,18 +142,24 @@ int dlt_daemon_init(DltDaemon *daemon,const char *runtime_directory, int verbose daemon->mode = DLT_USER_MODE_EXTERNAL; /* prepare filenames for configuration */ + + append_length = PATH_MAX - sizeof(DLT_RUNTIME_APPLICATION_CFG); if(runtime_directory[0]) - strcpy(daemon->runtime_application_cfg,runtime_directory); + strncpy(daemon->runtime_application_cfg,runtime_directory,append_length); else strcpy(daemon->runtime_application_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY); strcat(daemon->runtime_application_cfg,DLT_RUNTIME_APPLICATION_CFG); + + append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONTEXT_CFG); if(runtime_directory[0]) - strcpy(daemon->runtime_context_cfg,runtime_directory); + strncpy(daemon->runtime_context_cfg,runtime_directory,append_length); else strcpy(daemon->runtime_context_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY); strcat(daemon->runtime_context_cfg,DLT_RUNTIME_CONTEXT_CFG); - if(runtime_directory[0]) - strcpy(daemon->runtime_configuration,runtime_directory); + + append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONFIGURATION); + if(runtime_directory[0]) + strncpy(daemon->runtime_configuration,runtime_directory,append_length); else strcpy(daemon->runtime_configuration,DLT_RUNTIME_DEFAULT_DIRECTORY); strcat(daemon->runtime_configuration,DLT_RUNTIME_CONFIGURATION); -- cgit v1.2.1