From: Alan T. DeKok Date: Fri, 18 Mar 2022 00:05:17 +0000 (-0400) Subject: decode array of structs (whew!) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=367e933d70d9fca0b9a98a75495aa0a35a88d9f2;p=thirdparty%2Ffreeradius-server.git decode array of structs (whew!) --- diff --git a/src/protocols/dhcpv4/decode.c b/src/protocols/dhcpv4/decode.c index 00f1dd1b9c5..8721647bb13 100644 --- a/src/protocols/dhcpv4/decode.c +++ b/src/protocols/dhcpv4/decode.c @@ -428,6 +428,19 @@ static ssize_t decode_array(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t */ if (da_is_split_prefix(parent)) element_len = 8; + /* + * Array of structs. + */ + if (parent->type == FR_TYPE_STRUCT) { + while (p < end) { + slen = decode_value(ctx, out, parent, p, end - p, decode_ctx, false); + if (slen < 0) return slen - (p - data); + p += slen; + } + + return data_len; + } + if (element_len > 0) { size_t num_elements = (end - p) / element_len;