dst->enumv = src->enumv;
dst->type = src->type;
dst->tainted = src->tainted;
+ dst->safe = src->safe;
fr_dlist_entry_init(&dst->entry);
}
while ((vb = fr_dlist_next(list, vb))) value_box_verify(file, line, vb, talloced);
}
+
+
+/** Mark a value-box as "safe", of a particular type.
+ *
+ * Tainted data cannot be marked "safe". And once data is marked
+ * safe, it cannot be marked as a different type of "safe"
+ */
+int fr_value_box_mark_safe(fr_value_box_t *box, uint16_t safe)
+{
+ if (box->tainted) {
+ fr_strerror_const("Cannot mark data as 'safe' - it is 'tainted'");
+ return -1;
+ }
+
+ if (box->safe == safe) return 0;
+
+ if (box->safe != 0) {
+ fr_strerror_const("Data was already marked 'safe', of a different type");
+ return -1;
+ }
+
+ box->safe = safe;
+ return 0;
+}
+
+/** Mark a value-box as "unsafe"
+ *
+ * This always succeeds, and there are no side effects.
+ */
+void fr_value_box_mark_unsafe(fr_value_box_t *box)
+{
+ box->safe = 0;
+}
fr_type_t _CONST type; //!< Type of this value-box.
bool tainted; //!< i.e. did it come from an untrusted source
+ uint16_t _CONST safe; //!< more detailed safety
fr_dict_attr_t const *enumv; //!< Enumeration values.
int fr_value_unbox_ipaddr(fr_ipaddr_t *dst, fr_value_box_t *src);
+static inline CC_HINT(nonnull,always_inline) bool fr_value_box_is_safe(fr_value_box_t const *box, uint16_t safe)
+{
+ if (!safe) return false;
+
+ return (box->safe == safe);
+}
+
+int fr_value_box_mark_safe(fr_value_box_t *box, uint16_t safe) CC_HINT(nonnull);
+
+void fr_value_box_mark_unsafe(fr_value_box_t *box) CC_HINT(nonnull);
+
/** @name Box to box copying
*
* @{