]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set "is_known_width" flag for DNS labels
authorAlan T. DeKok <aland@freeradius.org>
Fri, 13 Aug 2021 15:08:19 +0000 (11:08 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 13 Aug 2021 17:53:27 +0000 (13:53 -0400)
which will let us encode DNS labels inside of structs, as that
is used in DHCPv6

src/lib/util/dict.h
src/lib/util/dict_tokenize.c
src/protocols/dhcpv6/base.c

index 5d968e896de76609bd65dfd09fb04b3aeae288f0..ce949be38b7a66ffcf2c180389514978072db389 100644 (file)
@@ -84,6 +84,9 @@ typedef struct {
        unsigned int            internal : 1;                   //!< Internal attribute, should not be received
                                                                ///< in protocol packets, should not be encoded.
        unsigned int            array : 1;                      //!< Pack multiples into 1 attr.
+
+       unsigned int            is_known_width : 1;             //!< is treated as if it has a known width for structs
+
        unsigned int            has_value : 1;                  //!< Has a value.
 
        unsigned int            virtual : 1;                    //!< for dynamic expansion
index 947c2d49995cb471d9ac875a6f7905f7fbe33cc4..99e5f1f08efb247405b934bc98cdc053b2643296 100644 (file)
@@ -262,6 +262,7 @@ static int dict_process_type_field(dict_tokenize_ctx_t *ctx, char const *name, f
                        return -1;
                }
 
+               flags->is_known_width = true;
                flags->length = length;
                *type_p = type;
                return 0;
@@ -983,7 +984,7 @@ static int dict_read_process_member(dict_tokenize_ctx_t *ctx, char **argv, int a
         *      so, complain if we're adding a variable sized member.
         */
        if (ctx->stack[ctx->stack_depth].da->flags.length &&
-           ((type == FR_TYPE_TLV) ||
+           ((type == FR_TYPE_TLV) || flags.is_known_width ||
             ((type == FR_TYPE_STRING) && !flags.length) ||
             ((type == FR_TYPE_OCTETS) && !flags.length))) {
                fr_strerror_printf("'struct' %s has fixed size %u, we cannot add a variable-sized member.",
index 6dfaaaaa3d97d13c74a4b1c424c1889c2a51d89d..12537f83bace6d91dad145e2673080ce666c6b06 100644 (file)
@@ -1031,6 +1031,8 @@ static bool attr_valid(UNUSED fr_dict_t *dict, UNUSED fr_dict_attr_t const *pare
                return false;
        }
 
+       flags->is_known_width = true;
+
        return true;
 }