Skip to content

Commit

Permalink
trust the dcursor, and don't check for flags.internal
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Sep 11, 2023
1 parent 65a8e8d commit bb791f1
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/lib/util/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -826,7 +823,7 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff,
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.
Expand All @@ -836,7 +833,9 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff,
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);
}
}

Expand Down

0 comments on commit bb791f1

Please sign in to comment.