]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update cursor only on success
authorAlan T. DeKok <aland@freeradius.org>
Sun, 29 Nov 2020 17:07:53 +0000 (12:07 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 29 Nov 2020 17:08:34 +0000 (12:08 -0500)
src/lib/util/struct.c

index 294887896328afd71aa53ea7d21f3e25eaee2b46..0cbef332de57718fb982260a7ea64fc66fe68e1a 100644 (file)
@@ -435,13 +435,6 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff,
                fr_pair_list_sort(&sorted->vp_group, pair_sort_increasing);
                fr_cursor_init(&child_cursor, &sorted->vp_group);
 
-               /*
-                *      Always skip the VP containing the struct.
-                *
-                *      @todo - do this only on success.
-                */
-               (void) fr_cursor_next(parent_cursor);
-
                /*
                 *      Build the da_stack for the new structure.
                 */
@@ -699,5 +692,11 @@ done:
                fr_dbuff_in(&hdr_dbuff, (uint16_t)len);
        }
 
+       /*
+        *      We've encoded the children, so tell the parent cursor
+        *      that we've encoded the parent.
+        */
+       if (cursor != parent_cursor) (void) fr_cursor_next(parent_cursor);
+
        return fr_dbuff_set(dbuff, &work_dbuff);
 }