From: Alan T. DeKok Date: Sun, 10 Oct 2021 11:54:40 +0000 (-0400) Subject: more / better errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18895519fdebd5f9897a7abbba133b9a952398be;p=thirdparty%2Ffreeradius-server.git more / better errors --- diff --git a/src/lib/util/struct.c b/src/lib/util/struct.c index fb85c5b87a4..d52b6acfae2 100644 --- a/src/lib/util/struct.c +++ b/src/lib/util/struct.c @@ -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); /*