]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dnp3: regenerates C code with script
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 19 Nov 2020 13:30:56 +0000 (14:30 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 3 Dec 2020 16:06:49 +0000 (17:06 +0100)
src/app-layer-dnp3-objects.c

index bfd0973d80da391904ef89576d55cd6b7289e09d..e71d6dd61eabe2d838ff225bc69e6fb173817582 100644 (file)
@@ -395,15 +395,15 @@ static int DNP3DecodeObjectG1V1(const uint8_t **buf, uint32_t *len,
     DNP3PointList *points)
 {
     DNP3ObjectG1V1 *object = NULL;
-    int bytes = (count / 8) + 1;
+    uint32_t bytes = (count / 8) + 1;
     uint32_t prefix = 0;
-    int point_index = start;
+    uint32_t point_index = start;
 
     if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
         goto error;
     }
 
-    for (int i = 0; i < bytes; i++) {
+    for (uint32_t i = 0; i < bytes; i++) {
 
         uint8_t octet;
 
@@ -447,6 +447,9 @@ static int DNP3DecodeObjectG1V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -498,6 +501,9 @@ static int DNP3DecodeObjectG2V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -538,6 +544,9 @@ static int DNP3DecodeObjectG2V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -592,6 +601,9 @@ static int DNP3DecodeObjectG2V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -643,15 +655,15 @@ static int DNP3DecodeObjectG3V1(const uint8_t **buf, uint32_t *len,
     DNP3PointList *points)
 {
     DNP3ObjectG3V1 *object = NULL;
-    int bytes = (count / 8) + 1;
+    uint32_t bytes = (count / 8) + 1;
     uint32_t prefix = 0;
-    int point_index = start;
+    uint32_t point_index = start;
 
     if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
         goto error;
     }
 
-    for (int i = 0; i < bytes; i++) {
+    for (uint32_t i = 0; i < bytes; i++) {
 
         uint8_t octet;
 
@@ -695,6 +707,9 @@ static int DNP3DecodeObjectG3V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -745,6 +760,9 @@ static int DNP3DecodeObjectG4V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -795,6 +813,9 @@ static int DNP3DecodeObjectG4V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -848,6 +869,9 @@ static int DNP3DecodeObjectG4V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -898,15 +922,15 @@ static int DNP3DecodeObjectG10V1(const uint8_t **buf, uint32_t *len,
     DNP3PointList *points)
 {
     DNP3ObjectG10V1 *object = NULL;
-    int bytes = (count / 8) + 1;
+    uint32_t bytes = (count / 8) + 1;
     uint32_t prefix = 0;
-    int point_index = start;
+    uint32_t point_index = start;
 
     if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
         goto error;
     }
 
-    for (int i = 0; i < bytes; i++) {
+    for (uint32_t i = 0; i < bytes; i++) {
 
         uint8_t octet;
 
@@ -950,6 +974,9 @@ static int DNP3DecodeObjectG10V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1001,6 +1028,9 @@ static int DNP3DecodeObjectG11V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1052,6 +1082,9 @@ static int DNP3DecodeObjectG11V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1106,6 +1139,9 @@ static int DNP3DecodeObjectG12V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1170,6 +1206,9 @@ static int DNP3DecodeObjectG12V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1231,15 +1270,15 @@ static int DNP3DecodeObjectG12V3(const uint8_t **buf, uint32_t *len,
     DNP3PointList *points)
 {
     DNP3ObjectG12V3 *object = NULL;
-    int bytes = (count / 8) + 1;
+    uint32_t bytes = (count / 8) + 1;
     uint32_t prefix = 0;
-    int point_index = start;
+    uint32_t point_index = start;
 
     if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
         goto error;
     }
 
-    for (int i = 0; i < bytes; i++) {
+    for (uint32_t i = 0; i < bytes; i++) {
 
         uint8_t octet;
 
@@ -1283,6 +1322,9 @@ static int DNP3DecodeObjectG13V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1328,6 +1370,9 @@ static int DNP3DecodeObjectG13V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1376,6 +1421,9 @@ static int DNP3DecodeObjectG20V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1430,6 +1478,9 @@ static int DNP3DecodeObjectG20V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1484,6 +1535,9 @@ static int DNP3DecodeObjectG20V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1538,6 +1592,9 @@ static int DNP3DecodeObjectG20V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1592,6 +1649,9 @@ static int DNP3DecodeObjectG20V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1632,6 +1692,9 @@ static int DNP3DecodeObjectG20V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1672,6 +1735,9 @@ static int DNP3DecodeObjectG20V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1712,6 +1778,9 @@ static int DNP3DecodeObjectG20V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1752,6 +1821,9 @@ static int DNP3DecodeObjectG21V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1806,6 +1878,9 @@ static int DNP3DecodeObjectG21V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1860,6 +1935,9 @@ static int DNP3DecodeObjectG21V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1914,6 +1992,9 @@ static int DNP3DecodeObjectG21V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -1968,6 +2049,9 @@ static int DNP3DecodeObjectG21V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2025,6 +2109,9 @@ static int DNP3DecodeObjectG21V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2082,6 +2169,9 @@ static int DNP3DecodeObjectG21V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2139,6 +2229,9 @@ static int DNP3DecodeObjectG21V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2196,6 +2289,9 @@ static int DNP3DecodeObjectG21V9(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2236,6 +2332,9 @@ static int DNP3DecodeObjectG21V10(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2276,6 +2375,9 @@ static int DNP3DecodeObjectG21V11(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2316,6 +2418,9 @@ static int DNP3DecodeObjectG21V12(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2356,6 +2461,9 @@ static int DNP3DecodeObjectG22V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2410,6 +2518,9 @@ static int DNP3DecodeObjectG22V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2464,6 +2575,9 @@ static int DNP3DecodeObjectG22V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2518,6 +2632,9 @@ static int DNP3DecodeObjectG22V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2572,6 +2689,9 @@ static int DNP3DecodeObjectG22V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2629,6 +2749,9 @@ static int DNP3DecodeObjectG22V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2686,6 +2809,9 @@ static int DNP3DecodeObjectG22V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2743,6 +2869,9 @@ static int DNP3DecodeObjectG22V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2800,6 +2929,9 @@ static int DNP3DecodeObjectG23V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2854,6 +2986,9 @@ static int DNP3DecodeObjectG23V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2908,6 +3043,9 @@ static int DNP3DecodeObjectG23V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -2962,6 +3100,9 @@ static int DNP3DecodeObjectG23V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3016,6 +3157,9 @@ static int DNP3DecodeObjectG23V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3073,6 +3217,9 @@ static int DNP3DecodeObjectG23V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3130,6 +3277,9 @@ static int DNP3DecodeObjectG23V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3187,6 +3337,9 @@ static int DNP3DecodeObjectG23V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3244,6 +3397,9 @@ static int DNP3DecodeObjectG30V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3298,6 +3454,9 @@ static int DNP3DecodeObjectG30V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3352,6 +3511,9 @@ static int DNP3DecodeObjectG30V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3392,6 +3554,9 @@ static int DNP3DecodeObjectG30V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3432,6 +3597,9 @@ static int DNP3DecodeObjectG30V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3486,6 +3654,9 @@ static int DNP3DecodeObjectG30V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3540,6 +3711,9 @@ static int DNP3DecodeObjectG31V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3594,6 +3768,9 @@ static int DNP3DecodeObjectG31V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3648,6 +3825,9 @@ static int DNP3DecodeObjectG31V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3705,6 +3885,9 @@ static int DNP3DecodeObjectG31V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3762,6 +3945,9 @@ static int DNP3DecodeObjectG31V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3802,6 +3988,9 @@ static int DNP3DecodeObjectG31V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3842,6 +4031,9 @@ static int DNP3DecodeObjectG31V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3896,6 +4088,9 @@ static int DNP3DecodeObjectG31V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -3950,6 +4145,9 @@ static int DNP3DecodeObjectG32V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4004,6 +4202,9 @@ static int DNP3DecodeObjectG32V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4058,6 +4259,9 @@ static int DNP3DecodeObjectG32V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4115,6 +4319,9 @@ static int DNP3DecodeObjectG32V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4172,6 +4379,9 @@ static int DNP3DecodeObjectG32V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4226,6 +4436,9 @@ static int DNP3DecodeObjectG32V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4280,6 +4493,9 @@ static int DNP3DecodeObjectG32V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4337,6 +4553,9 @@ static int DNP3DecodeObjectG32V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4394,6 +4613,9 @@ static int DNP3DecodeObjectG33V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4448,6 +4670,9 @@ static int DNP3DecodeObjectG33V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4502,6 +4727,9 @@ static int DNP3DecodeObjectG33V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4559,6 +4787,9 @@ static int DNP3DecodeObjectG33V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4616,6 +4847,9 @@ static int DNP3DecodeObjectG33V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4670,6 +4904,9 @@ static int DNP3DecodeObjectG33V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4724,6 +4961,9 @@ static int DNP3DecodeObjectG33V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4781,6 +5021,9 @@ static int DNP3DecodeObjectG33V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4838,6 +5081,9 @@ static int DNP3DecodeObjectG34V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4878,6 +5124,9 @@ static int DNP3DecodeObjectG34V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4918,6 +5167,9 @@ static int DNP3DecodeObjectG34V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -4958,6 +5210,9 @@ static int DNP3DecodeObjectG40V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5012,6 +5267,9 @@ static int DNP3DecodeObjectG40V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5066,6 +5324,9 @@ static int DNP3DecodeObjectG40V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5120,6 +5381,9 @@ static int DNP3DecodeObjectG40V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5174,6 +5438,9 @@ static int DNP3DecodeObjectG41V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5217,6 +5484,9 @@ static int DNP3DecodeObjectG41V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5260,6 +5530,9 @@ static int DNP3DecodeObjectG41V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5303,6 +5576,9 @@ static int DNP3DecodeObjectG41V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5346,6 +5622,9 @@ static int DNP3DecodeObjectG42V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5400,6 +5679,9 @@ static int DNP3DecodeObjectG42V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5454,6 +5736,9 @@ static int DNP3DecodeObjectG42V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5511,6 +5796,9 @@ static int DNP3DecodeObjectG42V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5568,6 +5856,9 @@ static int DNP3DecodeObjectG42V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5622,6 +5913,9 @@ static int DNP3DecodeObjectG42V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5676,6 +5970,9 @@ static int DNP3DecodeObjectG42V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5733,6 +6030,9 @@ static int DNP3DecodeObjectG42V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5790,6 +6090,9 @@ static int DNP3DecodeObjectG43V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5838,6 +6141,9 @@ static int DNP3DecodeObjectG43V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5886,6 +6192,9 @@ static int DNP3DecodeObjectG43V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5937,6 +6246,9 @@ static int DNP3DecodeObjectG43V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -5988,6 +6300,9 @@ static int DNP3DecodeObjectG43V5(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6036,6 +6351,9 @@ static int DNP3DecodeObjectG43V6(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6084,6 +6402,9 @@ static int DNP3DecodeObjectG43V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6135,6 +6456,9 @@ static int DNP3DecodeObjectG43V8(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6186,6 +6510,9 @@ static int DNP3DecodeObjectG50V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6226,6 +6553,9 @@ static int DNP3DecodeObjectG50V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6269,6 +6599,9 @@ static int DNP3DecodeObjectG50V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6309,6 +6642,9 @@ static int DNP3DecodeObjectG50V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6355,6 +6691,9 @@ static int DNP3DecodeObjectG51V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6395,6 +6734,9 @@ static int DNP3DecodeObjectG51V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6435,6 +6777,9 @@ static int DNP3DecodeObjectG52V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6475,6 +6820,9 @@ static int DNP3DecodeObjectG52V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6515,6 +6863,9 @@ static int DNP3DecodeObjectG70V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6614,6 +6965,9 @@ static int DNP3DecodeObjectG70V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6686,6 +7040,9 @@ static int DNP3DecodeObjectG70V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6765,6 +7122,9 @@ static int DNP3DecodeObjectG70V4(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6835,6 +7195,9 @@ static int DNP3DecodeObjectG70V5(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6896,6 +7259,9 @@ static int DNP3DecodeObjectG70V6(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -6955,6 +7321,9 @@ static int DNP3DecodeObjectG70V7(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7028,6 +7397,9 @@ static int DNP3DecodeObjectG70V8(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7075,15 +7447,15 @@ static int DNP3DecodeObjectG80V1(const uint8_t **buf, uint32_t *len,
     DNP3PointList *points)
 {
     DNP3ObjectG80V1 *object = NULL;
-    int bytes = (count / 8) + 1;
+    uint32_t bytes = (count / 8) + 1;
     uint32_t prefix = 0;
-    int point_index = start;
+    uint32_t point_index = start;
 
     if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
         goto error;
     }
 
-    for (int i = 0; i < bytes; i++) {
+    for (uint32_t i = 0; i < bytes; i++) {
 
         uint8_t octet;
 
@@ -7127,6 +7499,9 @@ static int DNP3DecodeObjectG81V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7178,6 +7553,9 @@ static int DNP3DecodeObjectG83V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7227,6 +7605,9 @@ static int DNP3DecodeObjectG83V1(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->data_objects != NULL) {
+            SCFree(object->data_objects);
+        }
         SCFree(object);
     }
 
@@ -7241,6 +7622,9 @@ static int DNP3DecodeObjectG86V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7292,6 +7676,9 @@ static int DNP3DecodeObjectG102V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7337,6 +7724,9 @@ static int DNP3DecodeObjectG120V1(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7388,6 +7778,9 @@ static int DNP3DecodeObjectG120V1(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->challenge_data != NULL) {
+            SCFree(object->challenge_data);
+        }
         SCFree(object);
     }
 
@@ -7407,6 +7800,9 @@ static int DNP3DecodeObjectG120V2(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7452,6 +7848,9 @@ static int DNP3DecodeObjectG120V2(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->mac_value != NULL) {
+            SCFree(object->mac_value);
+        }
         SCFree(object);
     }
 
@@ -7466,6 +7865,9 @@ static int DNP3DecodeObjectG120V3(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7509,6 +7911,9 @@ static int DNP3DecodeObjectG120V4(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7554,6 +7959,9 @@ static int DNP3DecodeObjectG120V5(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7624,6 +8032,12 @@ static int DNP3DecodeObjectG120V5(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->challenge_data != NULL) {
+            SCFree(object->challenge_data);
+        }
+        if (object->mac_value != NULL) {
+            SCFree(object->mac_value);
+        }
         SCFree(object);
     }
 
@@ -7643,6 +8057,9 @@ static int DNP3DecodeObjectG120V6(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7688,6 +8105,9 @@ static int DNP3DecodeObjectG120V6(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->wrapped_key_data != NULL) {
+            SCFree(object->wrapped_key_data);
+        }
         SCFree(object);
     }
 
@@ -7707,6 +8127,9 @@ static int DNP3DecodeObjectG120V7(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7777,6 +8200,9 @@ static int DNP3DecodeObjectG120V8(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7822,6 +8248,9 @@ static int DNP3DecodeObjectG120V8(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->certificate != NULL) {
+            SCFree(object->certificate);
+        }
         SCFree(object);
     }
 
@@ -7837,6 +8266,9 @@ static int DNP3DecodeObjectG120V9(const uint8_t **buf, uint32_t *len,
     uint32_t point_index = start;
     uint32_t offset;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7876,6 +8308,9 @@ static int DNP3DecodeObjectG120V9(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->mac_value != NULL) {
+            SCFree(object->mac_value);
+        }
         SCFree(object);
     }
 
@@ -7894,6 +8329,9 @@ static int DNP3DecodeObjectG120V10(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -7977,6 +8415,12 @@ static int DNP3DecodeObjectG120V10(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->user_public_key != NULL) {
+            SCFree(object->user_public_key);
+        }
+        if (object->certification_data != NULL) {
+            SCFree(object->certification_data);
+        }
         SCFree(object);
     }
 
@@ -7995,6 +8439,9 @@ static int DNP3DecodeObjectG120V11(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -8050,6 +8497,9 @@ static int DNP3DecodeObjectG120V11(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->master_challenge_data != NULL) {
+            SCFree(object->master_challenge_data);
+        }
         SCFree(object);
     }
 
@@ -8068,6 +8518,9 @@ static int DNP3DecodeObjectG120V12(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -8113,6 +8566,9 @@ static int DNP3DecodeObjectG120V12(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->challenge_data != NULL) {
+            SCFree(object->challenge_data);
+        }
         SCFree(object);
     }
 
@@ -8131,6 +8587,9 @@ static int DNP3DecodeObjectG120V13(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -8176,6 +8635,9 @@ static int DNP3DecodeObjectG120V13(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->encrypted_update_key_data != NULL) {
+            SCFree(object->encrypted_update_key_data);
+        }
         SCFree(object);
     }
 
@@ -8195,6 +8657,9 @@ static int DNP3DecodeObjectG120V14(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -8234,6 +8699,9 @@ static int DNP3DecodeObjectG120V14(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->digital_signature != NULL) {
+            SCFree(object->digital_signature);
+        }
         SCFree(object);
     }
 
@@ -8253,6 +8721,9 @@ static int DNP3DecodeObjectG120V15(const uint8_t **buf, uint32_t *len,
         goto error;
     }
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -8292,6 +8763,9 @@ static int DNP3DecodeObjectG120V15(const uint8_t **buf, uint32_t *len,
     return 1;
 error:
     if (object != NULL) {
+        if (object->mac != NULL) {
+            SCFree(object->mac);
+        }
         SCFree(object);
     }
 
@@ -8306,6 +8780,9 @@ static int DNP3DecodeObjectG121V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -8363,6 +8840,9 @@ static int DNP3DecodeObjectG122V1(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));
@@ -8420,6 +8900,9 @@ static int DNP3DecodeObjectG122V2(const uint8_t **buf, uint32_t *len,
     uint32_t prefix = 0;
     uint32_t point_index = start;
 
+    if (*len < count/8) {
+        goto error;
+    }
     while (count--) {
 
         object = SCCalloc(1, sizeof(*object));