From: Nick Porter Date: Wed, 27 Apr 2022 06:47:41 +0000 (+0100) Subject: Fix decoding of single TLV X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66b68f507fdd83a15641d22e05f774ef5180a762;p=thirdparty%2Ffreeradius-server.git Fix decoding of single TLV - use fr_dcursor_next_peek to check for multiple children so that the cursor doesn't move - extract the pair from the source list to append to the destination --- diff --git a/src/protocols/internal/decode.c b/src/protocols/internal/decode.c index ef98179cb52..955ad2399c1 100644 --- a/src/protocols/internal/decode.c +++ b/src/protocols/internal/decode.c @@ -94,7 +94,7 @@ static ssize_t internal_decode_tlv(TALLOC_CTX *ctx, fr_pair_list_t *head, fr_dic * we need to do an intermediary TLV * VP to retain the nesting structure. */ - if (fr_pair_dcursor_init(&cursor, &children) && fr_dcursor_next(&cursor)) { + if (fr_pair_dcursor_init(&cursor, &children) && fr_dcursor_next_peek(&cursor)) { fr_pair_t *tlv; tlv = fr_pair_afrom_da(ctx, parent_da); @@ -108,7 +108,7 @@ static ssize_t internal_decode_tlv(TALLOC_CTX *ctx, fr_pair_list_t *head, fr_dic fr_pair_append(head, tlv); } else { - fr_pair_append(head, fr_dcursor_head(&cursor)); + fr_pair_append(head, fr_dcursor_remove(&cursor)); } return fr_dbuff_set(dbuff, &work_dbuff); @@ -324,8 +324,9 @@ static ssize_t internal_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dic case FR_TYPE_TLV: case FR_TYPE_STRUCT: if (unlikely(tainted)) goto bad_tainted; - +WARN("Decode TLV"); slen = internal_decode_tlv(ctx, out, da, &work_dbuff, decode_ctx); +WARN("We have %pP", fr_pair_list_tail(out)); if (slen <= 0) goto error; break; @@ -339,6 +340,7 @@ static ssize_t internal_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dic * It's ok for this function to return 0 * we can have zero length strings. */ +WARN("Decode default"); slen = internal_decode_pair_value(ctx, out, da, &work_dbuff, tainted, decode_ctx); if (slen < 0) goto error; }