}
/*
- * Only some data types can be in arrays.
+ * Only some data types can be in arrays, because we need
+ * to be able to decode the various array members.
*/
if (flags->array) {
- switch (type) {
+ if (!flags->is_known_width) switch (type) {
default:
fr_strerror_printf("The 'array' flag cannot be used with attributes of type '%s'",
fr_type_to_str(type));
case FR_TYPE_UINT32:
case FR_TYPE_DATE:
case FR_TYPE_TIME_DELTA:
+ break;
+
case FR_TYPE_STRING:
case FR_TYPE_OCTETS:
+ if (!flags->length) {
+ fr_strerror_const("Variable length attributes cannot be marked as 'array'");
+ return false;
+ }
+
+ flags->is_known_width = 1;
+ break;
+
case FR_TYPE_STRUCT:
+ /*
+ * If we have arrays of structs, then the structure MUST be known width.
+ */
+ flags->is_known_width = 1;
break;
}
return false;
}
- /*
- * If we have arrays of structs, then the structure MUST be known width.
- */
- flags->is_known_width |= flags->array;
-
ALLOW_FLAG(extra);
ALLOW_FLAG(subtype);
ALLOW_FLAG(array);
break;
}
- flags->is_known_width |= (flags->length > 0); /* for fixed-size string / octets */
-
/*
* type_size is used to limit the maximum attribute number, so it's checked first.
*/