diff options
author | Lassi Marttala <lassi.lm.marttala@partner.bmw.com> | 2012-02-21 12:16:23 +0100 |
---|---|---|
committer | Christian Muck <christian.muck@bmw.de> | 2012-04-04 14:30:09 +0200 |
commit | 64646a665c9fafc4454c67b6212702ed59e01c87 (patch) | |
tree | 510bc41181cfd9a0edd71325c3d1b3dcf52aa570 /include/dlt | |
parent | 83059468ecd8ca6a68901f20477615cb58808c94 (diff) | |
download | DLT-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/dlt')
-rwxr-xr-x | include/dlt/dlt_common.h | 3 | ||||
-rwxr-xr-x | include/dlt/dlt_user_macros.h | 4 |
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); \ |