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

Function lomac_parse_element

freebsd/security/mac_lomac/mac_lomac.c:714–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712}
713
714static int
715lomac_parse_element(struct mac_lomac_element *element, char *string)
716{
717
718 if (strcmp(string, "high") == 0 || strcmp(string, "hi") == 0) {
719 element->mle_type = MAC_LOMAC_TYPE_HIGH;
720 element->mle_grade = MAC_LOMAC_TYPE_UNDEF;
721 } else if (strcmp(string, "low") == 0 || strcmp(string, "lo") == 0) {
722 element->mle_type = MAC_LOMAC_TYPE_LOW;
723 element->mle_grade = MAC_LOMAC_TYPE_UNDEF;
724 } else if (strcmp(string, "equal") == 0 ||
725 strcmp(string, "eq") == 0) {
726 element->mle_type = MAC_LOMAC_TYPE_EQUAL;
727 element->mle_grade = MAC_LOMAC_TYPE_UNDEF;
728 } else {
729 char *p0, *p1;
730 int d;
731
732 p0 = string;
733 d = strtol(p0, &p1, 10);
734
735 if (d < 0 || d > 65535)
736 return (EINVAL);
737 element->mle_type = MAC_LOMAC_TYPE_GRADE;
738 element->mle_grade = d;
739
740 if (p1 == p0 || *p1 != '\0')
741 return (EINVAL);
742 }
743
744 return (0);
745}
746
747/*
748 * Note: destructively consumes the string, make a local copy before calling

Callers 1

lomac_parseFunction · 0.85

Calls 2

strcmpFunction · 0.85
strtolFunction · 0.85

Tested by

no test coverage detected