diff options
author | Frederic Berat <fberat@de.adit-jv.com> | 2016-06-01 16:17:43 +0200 |
---|---|---|
committer | Christoph Lipka <clipka@jp.adit-jv.com> | 2016-10-24 13:39:55 +0900 |
commit | f1a32faa95358d7257acd267ca0e7568d3c5f7b0 (patch) | |
tree | 61077ae2d2a7cc852230871f83f9b12ec0b07955 /src/shared/dlt_common.c | |
parent | 657dbee1201e2e72952f978aad705f6358838f75 (diff) | |
download | DLT-daemon-f1a32faa95358d7257acd267ca0e7568d3c5f7b0.tar.gz |
process user message: Fix bound handling
On context and application registration, the data needs to be read in 2
parts. If the first part was at the end of the receiver buffer, it was
wrongly removed whereas the complete data is not full received and
therefore interpretable. This has to be fixed by not removing the data
before everything is checked.
Thus, while readjusting the buffer to the first found header, the offset
was not properly updated.
Signed-off-by: Frederic Berat <fberat@de.adit-jv.com>
Process User Messages: Fix buffer handling
In case application and context registration the buffer need to be read
two times. But before removing the data, the data need to be readjusted
to its origin. This was missing in a previous fix.
Furthermore, in case of corrupted description field, applications and
contexts will be registered anyway with the dummy description "Unknown".
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
Diffstat (limited to 'src/shared/dlt_common.c')
-rw-r--r-- | src/shared/dlt_common.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 1eee17d..8808801 100644 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -2270,12 +2270,12 @@ DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver) int dlt_receiver_check_and_get(DltReceiver *receiver, void *dest, unsigned int to_get, - unsigned int skip_header) + unsigned int flags) { unsigned int min_size = to_get; void *src = NULL; - if (skip_header) { + if (flags & DLT_RCV_SKIP_HEADER) { min_size += sizeof(DltUserHeader); } @@ -2283,23 +2283,23 @@ int dlt_receiver_check_and_get(DltReceiver *receiver, (receiver->bytesRcvd < (int32_t)min_size) || !receiver->buf || !dest) { - return -1; + return DLT_RETURN_WRONG_PARAMETER; } src = (void *)receiver->buf; - if (skip_header) { + if (flags & DLT_RCV_SKIP_HEADER) { src += sizeof(DltUserHeader); } - memset(dest, 0, to_get); - memcpy(dest, src, to_get); - if (dlt_receiver_remove(receiver, min_size) == -1) - { - dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n"); - return -1; + if (flags & DLT_RCV_REMOVE) { + if (dlt_receiver_remove(receiver, min_size) != DLT_RETURN_OK) + { + dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n"); + return DLT_RETURN_ERROR; + } } return to_get; |