MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mls_to_string

Function mls_to_string

freebsd/security/mac_mls/mac_mls.c:553–580  ·  view source on GitHub ↗

* mls_to_string() converts an MLS label to a string, and places the results * in the passed sbuf. It returns 0 on success, or EINVAL if there isn't * room in the sbuf. Note: the sbuf will be modified even in a failure case, * so the caller may need to revert the sbuf by restoring the offset if * that's undesired. */

Source from the content-addressed store, hash-verified

551 * that's undesired.
552 */
553static int
554mls_to_string(struct sbuf *sb, struct mac_mls *mm)
555{
556
557 if (mm->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
558 if (mls_element_to_string(sb, &mm->mm_effective) == -1)
559 return (EINVAL);
560 }
561
562 if (mm->mm_flags & MAC_MLS_FLAG_RANGE) {
563 if (sbuf_putc(sb, '(') == -1)
564 return (EINVAL);
565
566 if (mls_element_to_string(sb, &mm->mm_rangelow) == -1)
567 return (EINVAL);
568
569 if (sbuf_putc(sb, '-') == -1)
570 return (EINVAL);
571
572 if (mls_element_to_string(sb, &mm->mm_rangehigh) == -1)
573 return (EINVAL);
574
575 if (sbuf_putc(sb, ')') == -1)
576 return (EINVAL);
577 }
578
579 return (0);
580}
581
582static int
583mls_externalize_label(struct label *label, char *element_name,

Callers 1

mls_externalize_labelFunction · 0.85

Calls 2

mls_element_to_stringFunction · 0.85
sbuf_putcFunction · 0.85

Tested by

no test coverage detected