]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
ensure that we don't ask for length of DNS labels
authorAlan T. DeKok <aland@freeradius.org>
Fri, 13 Aug 2021 14:51:32 +0000 (10:51 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 13 Aug 2021 17:53:26 +0000 (13:53 -0400)
the length is not fixed, but is instead dependent on the length
of the label.  However, unlike normal "string" attributes, the
field is delimited, so we can figure out the length just by
looking at the data.

src/protocols/dhcpv6/base.c

index 2ee1d6a28f59fbb95ce6b982ace75ff232d68938..6dfaaaaa3d97d13c74a4b1c424c1889c2a51d89d 100644 (file)
@@ -151,6 +151,15 @@ size_t fr_dhcpv6_option_len(fr_pair_t const *vp)
 {
        switch (vp->vp_type) {
        case FR_TYPE_VARIABLE_SIZE:
+#ifndef NDEBUG
+               if (!vp->da->flags.extra &&
+                   ((vp->da->flags.subtype == FLAG_ENCODE_DNS_LABEL) ||
+                    (vp->da->flags.subtype == FLAG_ENCODE_PARTIAL_DNS_LABEL))) {
+                       fr_assert_fail("DNS labels MUST be encoded/decoded with their own function, and not with generic 'string' functions");
+                       return 0;
+               }
+#endif
+
                if (vp->da->flags.length) return vp->da->flags.length;  /* Variable type with fixed length */
                return vp->vp_length;