summaryrefslogtreecommitdiff
path: root/src/shared/dlt_common.c
diff options
context:
space:
mode:
authorSimon Brandner <simon.brandner@partner.bmw.de>2012-12-06 10:18:12 +0100
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2013-07-19 16:54:05 +0200
commitbe9c3bf964295883ff086dfb8c2ece38f833b355 (patch)
tree9faf2962efc5b7c24c98f5082d8afd4c2f7a2907 /src/shared/dlt_common.c
parent311b8896c144c5ff8c10dbc0d4c7832720292608 (diff)
downloadDLT-daemon-be9c3bf964295883ff086dfb8c2ece38f833b355.tar.gz
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 <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/shared/dlt_common.c')
-rwxr-xr-xsrc/shared/dlt_common.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 68d06c6..b2324b1 100755
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -67,6 +67,7 @@
#include <stdlib.h> /* for malloc(), free() */
#include <string.h> /* for strlen(), memcmp(), memmove() */
#include <time.h> /* for localtime(), strftime() */
+#include <limits.h> /* for NAME_MAX */
#include "dlt_common.h"
#include "dlt_common_cfg.h"
@@ -102,7 +103,7 @@ char dltSerialHeaderChar[DLT_ID_SIZE] = { 'D','L','S',1 };
/* internal logging parameters */
static int logging_mode = 0;
static int logging_level = 6;
-static char logging_filename[256] = "";
+static char logging_filename[NAME_MAX + 1] = "";
static FILE *logging_handle = 0;
char *message_type[] = {"log","app_trace","nw_trace","control","","","",""};
@@ -583,8 +584,10 @@ int dlt_filter_find(DltFilter *filter,const char *apid,const char *ctid, int ver
/* apid matches, now check for ctid */
if (ctid==0)
{
- /* check if empty ctid matches */
- if (memcmp(filter->ctid[num],"",DLT_ID_SIZE)==0)
+ /* check if empty ctid matches */
+ //if (memcmp(filter->ctid[num],"",DLT_ID_SIZE)==0)//coverity complains here about Out-of-bounds access.
+ char empty_ctid[DLT_ID_SIZE]="";
+ if (memcmp(filter->ctid[num],empty_ctid,DLT_ID_SIZE)==0)
{
return num;
}
@@ -1654,7 +1657,8 @@ int dlt_file_open(DltFile *file,const char *filename,int verbose)
file->handle = fopen(filename,"rb");
if (file->handle == 0)
{
- sprintf(str,"File %s cannot be opened!\n",filename);
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH - 1 ,"File %s cannot be opened!\n",filename);
+
dlt_log(LOG_ERR, str);
return -1;
}
@@ -1967,7 +1971,8 @@ void dlt_log_set_level(int level)
void dlt_log_set_filename(const char *filename)
{
- strncpy(logging_filename,filename,sizeof(logging_filename));
+ strncpy(logging_filename,filename,NAME_MAX);
+
}
void dlt_log_init(int mode)