From owner-p4-projects@FreeBSD.ORG Thu May 29 09:29:53 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F1DC437B404; Thu, 29 May 2003 09:29:52 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 73FDB37B401 for ; Thu, 29 May 2003 09:29:52 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0900F43F75 for ; Thu, 29 May 2003 09:29:52 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h4TGTp0U041083 for ; Thu, 29 May 2003 09:29:51 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h4TGTpwc041080 for perforce@freebsd.org; Thu, 29 May 2003 09:29:51 -0700 (PDT) Date: Thu, 29 May 2003 09:29:51 -0700 (PDT) Message-Id: <200305291629.h4TGTpwc041080@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 32011 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 May 2003 16:29:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=32011 Change 32011 by rwatson@rwatson_tislabs on 2003/05/29 09:29:44 Use strsep() to pass Biba and MLS labels into their elements rather than hand-parsing. Affected files ... .. //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#206 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#165 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#206 (text+ko) ==== @@ -765,38 +765,30 @@ static int mac_biba_parse(struct mac_biba *mac_biba, char *string) { - char *range, *rangeend, *rangehigh, *rangelow, *single; + char *rangehigh, *rangelow, *single; int error; - /* Do we have a range? */ - single = string; - range = index(string, '('); - if (range == single) + single = strsep(&string, "("); + if (*single == '\0') single = NULL; - rangelow = rangehigh = NULL; - if (range != NULL) { - /* Nul terminate the end of the single string. */ - *range = '\0'; - range++; - rangelow = range; - rangehigh = index(rangelow, '-'); - if (rangehigh == NULL) + + if (string != NULL) { + rangelow = strsep(&string, "-"); + if (string == NULL) return (EINVAL); - rangehigh++; - if (*rangelow == '\0' || *rangehigh == '\0') + rangehigh = strsep(&string, ")"); + if (string == NULL) return (EINVAL); - rangeend = index(rangehigh, ')'); - if (rangeend == NULL) + if (*string != '\0') return (EINVAL); - if (*(rangeend + 1) != '\0') - return (EINVAL); - /* Nul terminate the ends of the ranges. */ - *(rangehigh - 1) = '\0'; - *rangeend = '\0'; + } else { + rangelow = NULL; + rangehigh = NULL; } + KASSERT((rangelow != NULL && rangehigh != NULL) || (rangelow == NULL && rangehigh == NULL), - ("mac_biba_internalize_label: range mismatch")); + ("mac_biba_parse: range mismatch")); bzero(mac_biba, sizeof(*mac_biba)); if (single != NULL) { ==== //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#165 (text+ko) ==== @@ -730,38 +730,30 @@ static int mac_mls_parse(struct mac_mls *mac_mls, char *string) { - char *range, *rangeend, *rangehigh, *rangelow, *single; + char *rangehigh, *rangelow, *single; int error; - /* Do we have a range? */ - single = string; - range = index(string, '('); - if (range == single) + single = strsep(&string, "("); + if (*single == '\0') single = NULL; - rangelow = rangehigh = NULL; - if (range != NULL) { - /* Nul terminate the end of the single string. */ - *range = '\0'; - range++; - rangelow = range; - rangehigh = index(rangelow, '-'); - if (rangehigh == NULL) + + if (string != NULL) { + rangelow = strsep(&string, "-"); + if (string == NULL) return (EINVAL); - rangehigh++; - if (*rangelow == '\0' || *rangehigh == '\0') + rangehigh = strsep(&string, ")"); + if (string == NULL) return (EINVAL); - rangeend = index(rangehigh, ')'); - if (rangeend == NULL) + if (*string != '\0') return (EINVAL); - if (*(rangeend + 1) != '\0') - return (EINVAL); - /* Nul terminate the ends of the ranges. */ - *(rangehigh - 1) = '\0'; - *rangeend = '\0'; + } else { + rangelow = NULL; + rangehigh = NULL; } + KASSERT((rangelow != NULL && rangehigh != NULL) || (rangelow == NULL && rangehigh == NULL), - ("mac_mls_internalize_label: range mismatch")); + ("mac_mls_parse: range mismatch")); bzero(mac_mls, sizeof(*mac_mls)); if (single != NULL) {