summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkundatipradeep <35292742+kundatipradeep@users.noreply.github.com>2019-04-15 06:58:06 +0530
committerssugiura <39760799+ssugiura@users.noreply.github.com>2019-04-15 10:28:06 +0900
commit376bf6c1750d8d1c6bb1a5abc73e5b081d7b7825 (patch)
treee7669c95c4a0b4eb4348ffa2e3acb21048e8218b
parent9e5723b75937892e12e68bb2f18f5751ce3d458d (diff)
downloadDLT-daemon-376bf6c1750d8d1c6bb1a5abc73e5b081d7b7825.tar.gz
Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE res… (#116)
* Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE results in Memory corruption. As older version of DLT DLT_USER_RESENDBUF_MAX_SIZE is [DLT_USER_BUF_MAX_SIZE + 100] which contains space for extra headers, where as in DLT 2.18 the resend buffer is bound to DLT_USER_BUF_MAX_SIZE which results in memory corruption in dlt_buffer_read_block when the size of the data is more than DLT_USER_BUF_MAX_SIZE. Reason for not using "DLT_USER_RESENDBUF_MAX_SIZE" during dynamic memory allocation of resend buffer is as user has got the feasibility to alter the DLT_USER_BUF_MAX_SIZE using the environmental variables the resend buffer in any scenario to be greater then dlt_user.log_buf_len to accommodate the extra headers.
-rw-r--r--src/lib/dlt_user.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index 43fb025..f82f928 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -98,6 +98,9 @@ static int atexit_registered = 0;
/* used to disallow DLT usage in fork() child */
static int g_dlt_is_child = 0;
+/*Max DLT message size is 1390 bytes plus some extra header space to accomidate the resend buffer*/
+#define DLT_USER_EXTRA_BUFF_SIZE 100
+
/* Segmented Network Trace */
#define DLT_MAX_TRACE_SEGMENT_SIZE 1024
#define DLT_MESSAGE_QUEUE_NAME "/dlt_message_queue"
@@ -665,7 +668,7 @@ DltReturnValue dlt_init_common(void)
}
if (dlt_user.resend_buffer == NULL) {
- dlt_user.resend_buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+ dlt_user.resend_buffer = calloc(sizeof(unsigned char), (dlt_user.log_buf_len + DLT_USER_EXTRA_BUFF_SIZE));
if (dlt_user.resend_buffer == NULL) {
dlt_user_initialised = false;