diff options
author | Dinh Cong Toan <toan.dinhcong@vn.bosch.com> | 2021-06-04 11:08:16 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2021-06-30 10:54:59 +0900 |
commit | d9fe0567cd2922a8a2b9114d11ebb593e09ac557 (patch) | |
tree | 5d3743fd8cd68cf0b72fc42fc8106f431a61c1f6 | |
parent | 896d4c4a9f9cac915ab38e93d260d085e1adacc3 (diff) | |
download | DLT-daemon-d9fe0567cd2922a8a2b9114d11ebb593e09ac557.tar.gz |
dlt_common: Increment size after memcpy()
This commit fixes to increment read and write point only if memcpy()
succeeded in dlt_buffer_read_block() and dlt_buffer_write_block().
Related issues: https://github.com/GENIVI/dlt-daemon/issues/305
Signed-off-by: Sugiura, Saya <ssugiura@jp.adit-jv.com>
-rw-r--r-- | src/shared/dlt_common.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 22ae5e8..c489d2d 100644 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -2435,8 +2435,8 @@ void dlt_buffer_write_block(DltBuffer *buf, int *write, const unsigned char *dat /* write two blocks */ memcpy(buf->mem + *write, data, buf->size - (unsigned int) (*write)); memcpy(buf->mem, data + buf->size - *write, size - buf->size + (unsigned int) (*write)); + *write += (int) (size - buf->size); } - *write += (int) (size - buf->size); } } else { @@ -2462,9 +2462,8 @@ void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsig /* read two blocks */ memcpy(data, buf->mem + *read, buf->size - (unsigned int)(*read)); memcpy(data + buf->size - *read, buf->mem, size - buf->size + (unsigned int)(*read)); + *read += (int)(size - buf->size); } - - *read += (int)(size - buf->size); } } else { |