From 001350547af4b8f2a3747eab19fbbe0b33f06d37 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Thu, 19 Nov 2020 14:28:43 +0100 Subject: [PATCH] dnp3: fix signed integer overflow By using unsigned integers everywhere --- scripts/dnp3-gen/dnp3-gen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/dnp3-gen/dnp3-gen.py b/scripts/dnp3-gen/dnp3-gen.py index c522dfadbc..5b68203fa3 100755 --- a/scripts/dnp3-gen/dnp3-gen.py +++ b/scripts/dnp3-gen/dnp3-gen.py @@ -354,15 +354,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;