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

Function biba_to_string

freebsd/security/mac_biba/mac_biba.c:588–615  ·  view source on GitHub ↗

* biba_to_string() converts a Biba 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

586 * that's undesired.
587 */
588static int
589biba_to_string(struct sbuf *sb, struct mac_biba *mb)
590{
591
592 if (mb->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) {
593 if (biba_element_to_string(sb, &mb->mb_effective) == -1)
594 return (EINVAL);
595 }
596
597 if (mb->mb_flags & MAC_BIBA_FLAG_RANGE) {
598 if (sbuf_putc(sb, '(') == -1)
599 return (EINVAL);
600
601 if (biba_element_to_string(sb, &mb->mb_rangelow) == -1)
602 return (EINVAL);
603
604 if (sbuf_putc(sb, '-') == -1)
605 return (EINVAL);
606
607 if (biba_element_to_string(sb, &mb->mb_rangehigh) == -1)
608 return (EINVAL);
609
610 if (sbuf_putc(sb, ')') == -1)
611 return (EINVAL);
612 }
613
614 return (0);
615}
616
617static int
618biba_externalize_label(struct label *label, char *element_name,

Callers 1

biba_externalize_labelFunction · 0.85

Calls 2

biba_element_to_stringFunction · 0.85
sbuf_putcFunction · 0.85

Tested by

no test coverage detected