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

Function mls_parse

freebsd/security/mac_mls/mac_mls.c:654–705  ·  view source on GitHub ↗

* Note: destructively consumes the string, make a local copy before calling * if that's a problem. */

Source from the content-addressed store, hash-verified

652 * if that's a problem.
653 */
654static int
655mls_parse(struct mac_mls *mm, char *string)
656{
657 char *rangehigh, *rangelow, *effective;
658 int error;
659
660 effective = strsep(&string, "(");
661 if (*effective == '\0')
662 effective = NULL;
663
664 if (string != NULL) {
665 rangelow = strsep(&string, "-");
666 if (string == NULL)
667 return (EINVAL);
668 rangehigh = strsep(&string, ")");
669 if (string == NULL)
670 return (EINVAL);
671 if (*string != '\0')
672 return (EINVAL);
673 } else {
674 rangelow = NULL;
675 rangehigh = NULL;
676 }
677
678 KASSERT((rangelow != NULL && rangehigh != NULL) ||
679 (rangelow == NULL && rangehigh == NULL),
680 ("mls_parse: range mismatch"));
681
682 bzero(mm, sizeof(*mm));
683 if (effective != NULL) {
684 error = mls_parse_element(&mm->mm_effective, effective);
685 if (error)
686 return (error);
687 mm->mm_flags |= MAC_MLS_FLAG_EFFECTIVE;
688 }
689
690 if (rangelow != NULL) {
691 error = mls_parse_element(&mm->mm_rangelow, rangelow);
692 if (error)
693 return (error);
694 error = mls_parse_element(&mm->mm_rangehigh, rangehigh);
695 if (error)
696 return (error);
697 mm->mm_flags |= MAC_MLS_FLAG_RANGE;
698 }
699
700 error = mls_valid(mm);
701 if (error)
702 return (error);
703
704 return (0);
705}
706
707static int
708mls_internalize_label(struct label *label, char *element_name,

Callers 1

mls_internalize_labelFunction · 0.85

Calls 4

strsepFunction · 0.85
bzeroFunction · 0.85
mls_parse_elementFunction · 0.85
mls_validFunction · 0.85

Tested by

no test coverage detected