fr_strerror_printf("ERROR: Cannot encode NULL TLV");
return NULL;
}
+ if (vp->length > room) return 0; /* can't chop TLVs to fit */
break;
default: /* unknown type: ignore it */
/*
* Ignore TLVs that don't have data, OR
- * have too much data.
+ * have too much data to fit in the
+ * packet, OR have too much data to fit
+ * in the attribute.
*/
if (vp->flags.has_tlv &&
- (!vp->vp_tlv || (vp->length > room))) return 0;
+ (!vp->vp_tlv || (vp->length > room) ||
+
+ /*
+ * 6 + 1 (vsa_tlen) + 1 (vsa_llen)
+ * + 1 (vsa_offset).
+ */
+ (vp->length > (255 - 9)))) return 0;
/*