From: Alan T. DeKok Date: Mon, 11 Sep 2023 10:23:21 +0000 (-0400) Subject: trust the dcursor, and don't check for flags.internal X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb791f1d7bd0e61611caaf22db4b6ac1221e369b;p=thirdparty%2Ffreeradius-server.git trust the dcursor, and don't check for flags.internal --- diff --git a/src/lib/util/struct.c b/src/lib/util/struct.c index de04ba540e2..344f0ba8311 100644 --- a/src/lib/util/struct.c +++ b/src/lib/util/struct.c @@ -687,10 +687,9 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff, return offset; } - do { - vp = fr_dcursor_next(cursor); - if (!vp || !vp->da->flags.internal) break; - } while (vp != NULL); + vp = fr_dcursor_next(cursor); + if (!vp) break; + goto next; } @@ -742,10 +741,8 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff, raw: if (fr_value_box_to_network(&work_dbuff, &vp->data) <= 0) return PAIR_ENCODE_FATAL_ERROR; - do { - vp = fr_dcursor_next(cursor); - if (!vp || !vp->da->flags.internal) break; - } while (vp != NULL); + vp = fr_dcursor_next(cursor); + if (!vp) break; if (child->flags.array && (vp->da == child)) goto redo; } @@ -817,7 +814,7 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff, done: vp = fr_dcursor_current(cursor); - if (tlv) { + if (tlv && vp) { ssize_t slen; if (!encode_cursor) { @@ -826,7 +823,7 @@ done: return PAIR_ENCODE_FATAL_ERROR; } - fr_proto_da_stack_build(da_stack, vp ? vp->da : NULL); + fr_proto_da_stack_build(da_stack, vp->da); /* * Encode any TLV attributes which are part of this structure. @@ -836,7 +833,9 @@ done: if (slen < 0) return slen; vp = fr_dcursor_current(cursor); - fr_proto_da_stack_build(da_stack, vp ? vp->da : NULL); + if (!vp) break; + + fr_proto_da_stack_build(da_stack, vp->da); } }