summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/dlt/dlt_common.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index a418e7d..f4248ea 100644
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -313,14 +313,21 @@ enum {
{ memcpy(dst, src, DLT_ID_SIZE); src += DLT_ID_SIZE; length -= DLT_ID_SIZE; } \
}
-# define DLT_MSG_READ_STRING(dst, src, maxlength, length) \
+#define DLT_MSG_READ_STRING(dst, src, maxlength, dstlength, length) \
+{ \
+ if ((maxlength < 0) || (length <= 0) || (dstlength < length) || (maxlength < length)) \
{ \
- if (((maxlength) < 0) || ((length) < 0) || ((maxlength) < (length))) \
- { maxlength = -1; } \
- else \
- { memcpy(dst, src, length); dlt_clean_string(dst, length); dst[length] = 0; \
- src += length; maxlength -= length; } \
- }
+ maxlength = -1; \
+ } \
+ else \
+ { \
+ memcpy(dst, src, length); \
+ dlt_clean_string(dst, length); \
+ dst[length] = 0; \
+ src += length; \
+ maxlength -= length; \
+ } \
+}
# define DLT_MSG_READ_NULL(src, maxlength, length) \
{ \