diff options
author | jiripopek <Jiri.Popek@bmw.de> | 2019-04-04 14:13:34 +0200 |
---|---|---|
committer | ssugiura <39760799+ssugiura@users.noreply.github.com> | 2019-04-11 19:55:38 +0900 |
commit | 9e5723b75937892e12e68bb2f18f5751ce3d458d (patch) | |
tree | 30ec50fc70f83a145e43c4e635023905c9b21e54 | |
parent | eb3dcd26c80c4ac6e431b09b50b0861b9753ceea (diff) | |
download | DLT-daemon-9e5723b75937892e12e68bb2f18f5751ce3d458d.tar.gz |
Fixed memory leak when receiving network traces of 0xFFFF length
0xFFFF was used as a magic number in the length field of a network
message in order to trigger a resend. DLT library will now use the
nw_trace_type field and a custom type to do this, thus assuring no
external client of the library can reach this
value(DLT_NW_TRACE_RESEND).
-rw-r--r-- | include/dlt/dlt_types.h | 2 | ||||
-rw-r--r-- | src/lib/dlt_user.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/include/dlt/dlt_types.h b/include/dlt/dlt_types.h index 6a46c08..c47ba50 100644 --- a/include/dlt/dlt_types.h +++ b/include/dlt/dlt_types.h @@ -158,7 +158,7 @@ typedef enum DLT_NW_TRACE_USER_DEFINED4 = 0x0C, DLT_NW_TRACE_USER_DEFINED5 = 0x0D, DLT_NW_TRACE_USER_DEFINED6 = 0x0E, - DLT_NW_TRACE_USER_DEFINED7 = 0x0F, + DLT_NW_TRACE_RESEND = 0x0F, /**< Mark a resend */ DLT_NW_TRACE_MAX /**< maximum value, used for range check */ } DltNetworkTraceType; diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index cb7f570..43fb025 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -2956,7 +2956,8 @@ void dlt_user_trace_network_segmented_thread(void *unused) } /* Indicator just to try to flush the buffer */ - if (data->payload_len == DLT_DELAYED_RESEND_INDICATOR_PATTERN) { + /* DLT_NW_TRACE_RESEND custom type is used to mark a resend */ + if(data->nw_trace_type == DLT_NW_TRACE_RESEND) { /* Sleep 100ms, to allow other process to read FIFO */ usleep(100 * 1000); @@ -3530,7 +3531,8 @@ DltReturnValue dlt_user_queue_resend(void) if (resend_data == NULL) return DLT_RETURN_ERROR; - resend_data->payload_len = DLT_DELAYED_RESEND_INDICATOR_PATTERN; + /* DLT_NW_TRACE_RESEND custom type is used to mark a resend */ + resend_data->nw_trace_type = DLT_NW_TRACE_RESEND; /* Open queue if it is not open */ if (dlt_init_message_queue() < DLT_RETURN_OK) { |