summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLassi Marttala <lassi.lm.marttala@partner.bmw.com>2012-02-21 12:16:23 +0100
committerChristian Muck <christian.muck@bmw.de>2012-04-04 14:30:09 +0200
commit64646a665c9fafc4454c67b6212702ed59e01c87 (patch)
tree510bc41181cfd9a0edd71325c3d1b3dcf52aa570 /include
parent83059468ecd8ca6a68901f20477615cb58808c94 (diff)
downloadDLT-daemon-64646a665c9fafc4454c67b6212702ed59e01c87.tar.gz
GENDLT-15, Avoid buffer overrun with snprintf().
Check return value of dlt_user_log_write_start(_id) correctly. Reduce the number of applications if allocation fails. Make dlt_user_log_write_start inline Improve error checking in dlt_user_log_write_start_id Use databuffersize to avoid reallocations Signed-off-by: Christian Muck <christian.muck@bmw.de>
Diffstat (limited to 'include')
-rwxr-xr-xinclude/dlt/dlt_common.h3
-rwxr-xr-xinclude/dlt/dlt_user_macros.h4
2 files changed, 4 insertions, 3 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index 686df19..19ee4d5 100755
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -200,7 +200,7 @@
\
if(_verbose) \
{ \
- sprintf(_strbuf, "%s()\n",__func__); \
+ snprintf(_strbuf, 255, "%s()\n",__func__); \
dlt_log(LOG_INFO, _strbuf); \
} \
}
@@ -376,6 +376,7 @@ typedef struct sDltMessage
uint8_t headerbuffer[sizeof(DltStorageHeader)+
sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra)+sizeof(DltExtendedHeader)]; /**< buffer for loading complete header */
uint8_t *databuffer; /**< buffer for loading payload */
+ int32_t databuffersize;
/* header values of current loaded message */
DltStorageHeader *storageheader; /**< pointer to storage header of current loaded header */
diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h
index 17a8ddb..1f95f3c 100755
--- a/include/dlt/dlt_user_macros.h
+++ b/include/dlt/dlt_user_macros.h
@@ -161,7 +161,7 @@ extern DltContext CONTEXT;
#define DLT_LOG(CONTEXT,LOGLEVEL,ARGS...) \
{ \
DltContextData log; \
- if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)) \
+ if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)>0) \
{ \
ARGS; \
dlt_user_log_write_finish(&log); \
@@ -185,7 +185,7 @@ extern DltContext CONTEXT;
#define DLT_LOG_ID(CONTEXT,LOGLEVEL,MSGID,ARGS...) \
{ \
DltContextData log; \
- if (dlt_user_log_write_start_id(&CONTEXT,&log,LOGLEVEL,MSGID)) \
+ if (dlt_user_log_write_start_id(&CONTEXT,&log,LOGLEVEL,MSGID)>0) \
{ \
ARGS; \
dlt_user_log_write_finish(&log); \