]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dnp3: fix signed integer overflow
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 19 Nov 2020 13:28:43 +0000 (14:28 +0100)
committerShivani Bhardwaj <shivanib134@gmail.com>
Thu, 3 Dec 2020 22:39:55 +0000 (04:09 +0530)
By using unsigned integers everywhere

scripts/dnp3-gen/dnp3-gen.py

index 0396b6d5c654635fe0ba04ab3d651a04ecd9af16..c5f2ce5668789dbc7c289d74547638a94a1e0839 100755 (executable)
@@ -359,15 +359,15 @@ static int DNP3DecodeObjectG{{object.group}}V{{object.variation}}(const uint8_t
     DNP3PointList *points)
 {
     DNP3ObjectG{{object.group}}V{{object.variation}} *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;