correct check on max array size
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 1 Jul 2025 12:42:58 +0000 (14:42 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 1 Jul 2025 12:42:58 +0000 (14:42 +0200)
parse.h

diff --git a/parse.h b/parse.h
index fdae8b9a96c3e28ffd62bfa727d312a057ba8f18..89037e79f91caf11eed3bf6d9038379ea60ee14c 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -342,7 +342,7 @@ __BEGIN_DECLS
    @param field data from structure
 */
 #define SERIAL_ARRAY(name, field)                                          \
-    if (field##_len < _maxlen - len) {                                     \
+    if (field##_len <= _maxlen - len) {                                    \
         memcpy (_buffer + len, field, (uint16_t)field##_len);              \
         len += field##_len;                                                \
     } else {                                                               \
@@ -359,7 +359,7 @@ __BEGIN_DECLS
    @param field data from structure
 */
 #define SERIAL_TAB(name, field)                                            \
-    if ((int)sizeof (field) < _maxlen - len) {                             \
+    if ((int)sizeof (field) <= _maxlen - len) {                            \
         memcpy (_buffer + len, field, (uint16_t)sizeof (field));           \
         len += sizeof (field);                                             \
     } else {                                                               \