From: Alan T. DeKok Date: Fri, 8 Sep 2023 14:59:48 +0000 (-0400) Subject: use fr_pair_raw_from_network() instead of hand-rolling it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1b68ecda833610efad3775fd160f601a9e92994;p=thirdparty%2Ffreeradius-server.git use fr_pair_raw_from_network() instead of hand-rolling it --- diff --git a/src/lib/eap_aka_sim/decode.c b/src/lib/eap_aka_sim/decode.c index 9fd55aa9f85..bea787222f0 100644 --- a/src/lib/eap_aka_sim/decode.c +++ b/src/lib/eap_aka_sim/decode.c @@ -32,6 +32,7 @@ RCSID("$Id$") #include #include #include +#include #include #include "attrs.h" @@ -525,7 +526,6 @@ static ssize_t sim_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_di fr_pair_t *vp; uint8_t const *p = data; size_t prefix = 0; - fr_dict_attr_t *unknown; fr_aka_sim_ctx_t *packet_ctx = decode_ctx; @@ -653,6 +653,8 @@ static ssize_t sim_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_di break; case FR_TYPE_OCTETS: + if (parent->flags.is_unknown) goto raw; + /* * Get the number of bytes we expect before the value */ @@ -696,31 +698,16 @@ static ssize_t sim_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_di #endif fr_assert(parent->parent); - /* - * Re-write the attribute to be "raw". It is - * therefore of type "octets", and will be - * handled below. - */ - parent = unknown = fr_dict_unknown_attr_afrom_da(ctx, parent); - if (!parent) { - fr_strerror_printf_push("%s[%d]: Internal sanity check failed", __FUNCTION__, __LINE__); - return -1; - } + if (fr_pair_raw_from_network(ctx, out, parent, p, attr_len) < 0) return -1; + + return attr_len; } + fr_assert(!parent->flags.is_unknown); + vp = fr_pair_afrom_da(ctx, parent); if (!vp) return -1; - /* - * For unknown attributes copy the entire value, not skipping - * any reserved bytes. - */ - if (parent->flags.is_unknown) { - fr_pair_value_memdup(vp, p, attr_len, true); - vp->vp_length = attr_len; - goto done; - } - switch (parent->type) { /* * 0 1 2 3