diff options
author | Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com> | 2021-05-10 14:02:41 +0700 |
---|---|---|
committer | Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com> | 2021-05-10 14:02:41 +0700 |
commit | ad8a6ab070803f2b0e0fa177fd6638c10db2dde3 (patch) | |
tree | c193ae5c2b919f89415a815b78ab54a7661a2619 /src/shared/dlt_common.c | |
parent | b95044abb202838837b0566efc40ae26308a4bb4 (diff) | |
download | DLT-daemon-ad8a6ab070803f2b0e0fa177fd6638c10db2dde3.tar.gz |
daemon: check the conf inputs
The configuration of memory buffer size must be carefully
parsed and validated to avoid segmentation fault
Any misleading information in configuration file must be
considered as major error and dlt-daemon should stop
and raise error message to stderr
This commit also corrects error handling of
dlt_buffer_init_dynamic().
Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
Diffstat (limited to 'src/shared/dlt_common.c')
-rw-r--r-- | src/shared/dlt_common.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 9fe6c88..507c8ad 100644 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -2350,6 +2350,14 @@ DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32 head->write = 0; head->count = 0; buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead)); + + if (buf->min_size < (uint32_t)sizeof(DltBufferHead)) { + dlt_vlog(LOG_ERR, + "%s: min_size is too small [%u]\n", + __func__, buf->min_size); + return DLT_RETURN_WRONG_PARAMETER; + } + buf->size = (uint32_t) (buf->min_size - sizeof(DltBufferHead)); dlt_vlog(LOG_DEBUG, |