From: Arran Cudbard-Bell Date: Sun, 11 Jan 2026 10:16:38 +0000 (+0000) Subject: internal-decode: Allow decoding of empty groups (groups with no children) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fd420e195f42b2b67d7b69e1a7b3df490a94e43;p=thirdparty%2Ffreeradius-server.git internal-decode: Allow decoding of empty groups (groups with no children) --- diff --git a/src/protocols/internal/decode.c b/src/protocols/internal/decode.c index c76edc7c63c..9d6324ea0a8 100644 --- a/src/protocols/internal/decode.c +++ b/src/protocols/internal/decode.c @@ -121,7 +121,7 @@ static ssize_t internal_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dic * field (allows for future extensions). * * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1kk + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |tlen |llen |t|e| Type (min) | Length (min) | value... * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -253,8 +253,13 @@ static ssize_t internal_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dic return fr_pair_decode_slen(slen, fr_dbuff_start(&work_dbuff), fr_dbuff_current(&work_dbuff)); } } + /* + * It's ok for this function to return 0 + * we can have empty groups (i.e. groups + * with no children) + */ slen = internal_decode_structural(ctx, out, da, &work_dbuff, decode_ctx); - if (slen <= 0) goto error; + if (slen < 0) goto error; break; default: diff --git a/src/tests/unit/protocols/internal/decode.txt b/src/tests/unit/protocols/internal/decode.txt index 47cde44754d..0acf2827e31 100644 --- a/src/tests/unit/protocols/internal/decode.txt +++ b/src/tests/unit/protocols/internal/decode.txt @@ -37,6 +37,10 @@ match User-Name = "0123456789012345678901234567890123456789012345678901234567890 returned match 304 +# Decode an empty grouping attribute (this is a regression test) +decode-pair 00 1a 04 20 2c 50 00 +match Vendor-Specific = { FreeRADIUS = { } } + # # Edge cases # @@ -77,4 +81,4 @@ match -2 # count -match 40 +match 42