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 /src/examples/dlt-example-user-func.c | |
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 'src/examples/dlt-example-user-func.c')
-rwxr-xr-x | src/examples/dlt-example-user-func.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/examples/dlt-example-user-func.c b/src/examples/dlt-example-user-func.c index e716335..75db1b0 100755 --- a/src/examples/dlt-example-user-func.c +++ b/src/examples/dlt-example-user-func.c @@ -240,28 +240,28 @@ int main(int argc, char* argv[]) if (gflag) { /* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */ - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,10)) + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,10)>0) { dlt_user_log_write_finish(&mycontextdata); } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,11)) + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,11)>0) { dlt_user_log_write_uint16(&mycontextdata,1011); dlt_user_log_write_finish(&mycontextdata); } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,12)) + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,12)>0) { dlt_user_log_write_uint32(&mycontextdata,1012); dlt_user_log_write_uint32(&mycontextdata,1013); dlt_user_log_write_finish(&mycontextdata); } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,13)) + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,13)>0) { dlt_user_log_write_uint8(&mycontextdata,123); dlt_user_log_write_float32(&mycontextdata,1.12); dlt_user_log_write_finish(&mycontextdata); } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,14)) + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,14)>0) { dlt_user_log_write_string(&mycontextdata,"DEAD BEEF"); dlt_user_log_write_finish(&mycontextdata); @@ -275,7 +275,7 @@ int main(int argc, char* argv[]) if (gflag) { /* Non-verbose mode */ - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_WARN,num)) + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_WARN,num)>0) { dlt_user_log_write_int(&mycontextdata,num); dlt_user_log_write_string(&mycontextdata,text); @@ -285,7 +285,7 @@ int main(int argc, char* argv[]) else { /* Verbose mode */ - if (dlt_user_log_write_start(&mycontext,&mycontextdata,DLT_LOG_WARN)) + if (dlt_user_log_write_start(&mycontext,&mycontextdata,DLT_LOG_WARN)>0) { dlt_user_log_write_int(&mycontextdata,num); dlt_user_log_write_string(&mycontextdata,text); |