]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dnp3: adds bounds check for prefix chararray
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 8 Jul 2021 13:01:15 +0000 (15:01 +0200)
committerShivani Bhardwaj <shivanib134@gmail.com>
Fri, 8 Oct 2021 16:34:32 +0000 (22:04 +0530)
Ticket: #4558
Avoids intra structure overflow

(cherry picked from commit 126a7dcb4f1818a806c882c54da864992bb304d5)

scripts/dnp3-gen/dnp3-gen.py

index 75a127623cb68aa0aa6905473279c04bf1561d65..4a308de6f9f75438ea4d6157ce64a9cc8cbd4fb2 100755 (executable)
@@ -518,6 +518,9 @@ static int DNP3DecodeObjectG{{object.group}}V{{object.variation}}(const uint8_t
         }
 {% elif field.type == "chararray" %}
 {% if field.len_from_prefix %}
+        if (prefix - (offset - *len) >= {{field.size}}) {
+            goto error;
+        }
         object->{{field.len_field}} = prefix - (offset - *len);
 {% endif %}
         if (object->{{field.len_field}} > 0) {