]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
still go to "next" attribute if there's no data encoded
authorAlan T. DeKok <aland@freeradius.org>
Wed, 14 Dec 2022 13:12:35 +0000 (08:12 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 15 Dec 2022 14:19:35 +0000 (09:19 -0500)
RFC 2865 Section 5 days of length zero (0) MUST NOT be sent;
omit the entire attribute instead.

src/protocols/radius/encode.c

index 652cfd0821b79d6961c2ab26c3c5c81b9b7e3ab7..c606c59dfce583269309735373b07dd359a71349 100644 (file)
@@ -287,7 +287,7 @@ static ssize_t encode_tlv_children(fr_dbuff_t *dbuff,
                         *      Call ourselves recursively to encode children.
                         */
                        slen = encode_tlv_children(&work_dbuff, da_stack, depth, &child_cursor, encode_ctx);
-                       if (slen <= 0) {
+                       if (slen < 0) {
                                if (slen == PAIR_ENCODE_SKIPPED) continue;
                                return slen;
                        }
@@ -298,7 +298,7 @@ static ssize_t encode_tlv_children(fr_dbuff_t *dbuff,
                } else {
                        slen = encode_attribute(&work_dbuff, da_stack, depth + 1, cursor, encode_ctx);
                }
-               if (slen <= 0) {
+               if (slen < 0) {
                        if (slen == PAIR_ENCODE_SKIPPED) continue;
                        return slen;
                }
@@ -393,7 +393,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
        if ((vp->da->type == FR_TYPE_STRUCT) || (da->type == FR_TYPE_STRUCT)) {
                slen = fr_struct_to_network(&work_dbuff, da_stack, depth, cursor, encode_ctx, encode_value,
                                            encode_tlv_children);
-               if (slen <= 0) return slen;
+               if (slen < 0) return slen;
 
                vp = fr_dcursor_current(cursor);
                fr_proto_da_stack_build(da_stack, vp ? vp->da : NULL);
@@ -509,7 +509,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff,
        default:
        encode:
                slen = fr_value_box_to_network(&value_dbuff, &vp->data);
-               if (slen <= 0) return slen;
+               if (slen < 0) return slen;
                break;
        }
 
@@ -1153,7 +1153,7 @@ static ssize_t encode_vendor(fr_dbuff_t *dbuff,
                } else {
                        slen = encode_vendor_attr(&work_dbuff, da_stack, depth, &child_cursor, encode_ctx);
                }
-               if (slen <= 0) {
+               if (slen < 0) {
                        if (slen == PAIR_ENCODE_SKIPPED) continue;
                        return slen;
                }
@@ -1213,7 +1213,7 @@ static ssize_t encode_vsa(fr_dbuff_t *dbuff,
                fr_assert(da_stack->da[depth + 1]->type == FR_TYPE_VENDOR);
 
                slen = encode_vendor(&work_dbuff, da_stack, depth + 1, &child_cursor, encode_ctx);
-               if (slen <= 0) {
+               if (slen < 0) {
                        if (slen == PAIR_ENCODE_SKIPPED) continue;
                        return slen;
                }