]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more / better errors
authorAlan T. DeKok <aland@freeradius.org>
Sun, 10 Oct 2021 11:54:40 +0000 (07:54 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 10 Oct 2021 12:24:07 +0000 (08:24 -0400)
src/lib/util/struct.c

index fb85c5b87a40ad085a3a0e00a8bad512e75e17c1..d52b6acfae25c71e7dc0c5edbe68609c6f7ac64c 100644 (file)
@@ -509,9 +509,15 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff,
         *      given parent, then allow encoding of that struct, too.
         *      This allows us to encode structures automatically,
         *      even if key fields are omitted.
+        *
+        *      Note that this check catches TLVs which are "flat" and
+        *      not nested.  We could fix that by adding a special
+        *      case, but it's better to just fix everything to handle
+        *      nested attributes.
         */
        if (vp && (vp->da->parent != parent)) {
-               fr_strerror_printf("%s: struct encoding is missing previous attributes", __FUNCTION__);
+               fr_strerror_printf("%s: struct encoding is missing previous attributes (parent %s, expecting %s)",
+                                  __FUNCTION__, vp->da->parent->name, parent->name);
                return -1;
        }
 
@@ -746,6 +752,12 @@ done:
        if (tlv) {
                ssize_t slen;
 
+               if (!encode_tlv) {
+                       fr_strerror_printf("Asked to encode TLV %s, but not passed an encoding function",
+                                          tlv->name);
+                       return -1;
+               }
+
                fr_proto_da_stack_build(da_stack, vp ? vp->da : NULL);
 
                /*