From owner-p4-projects@FreeBSD.ORG Mon Nov 28 22:07:03 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3E94716A423; Mon, 28 Nov 2005 22:07:03 +0000 (GMT) X-Original-To: perforce@freebsd.org 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 199E916A420 for ; Mon, 28 Nov 2005 22:07:03 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D292943D5A for ; Mon, 28 Nov 2005 22:07:02 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jASM72xt024492 for ; Mon, 28 Nov 2005 22:07:02 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jASM72W7024489 for perforce@freebsd.org; Mon, 28 Nov 2005 22:07:02 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 28 Nov 2005 22:07:02 GMT Message-Id: <200511282207.jASM72W7024489@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 Cc: Subject: PERFORCE change 87385 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2005 22:07:04 -0000 http://perforce.freebsd.org/chv.cgi?CH=87385 Change 87385 by rwatson@rwatson_peppercorn on 2005/11/28 22:07:01 Make the class file parser a little more flexible and correct: when a comment is encountered in getauclassent(), don't abort parsing, just skip to the next line. Implement getauclassnam() using getauclassent() to fix the same bug there. This parser could be further improved. Affected files ... .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_class.c#5 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_class.c#5 (text+ko) ==== @@ -146,10 +146,18 @@ return (NULL); } - if (fgets(linestr, AU_LINE_MAX, fp) == NULL) { - pthread_mutex_unlock(&mutex); - return (NULL); + /* + * Read until next non-comment line is found, or EOF. + */ + while (1) { + if (fgets(linestr, AU_LINE_MAX, fp) == NULL) { + pthread_mutex_unlock(&mutex); + return (NULL); + } + if (linestr[0] != '#') + break; } + /* Remove trailing new line character. */ if ((nl = strrchr(linestr, '\n')) != NULL) *nl = '\0'; @@ -180,7 +188,6 @@ getauclassnam(const char *name) { struct au_class_ent *c; - char *nl; if (name == NULL) return (NULL); @@ -201,24 +208,16 @@ return (NULL); } - while(fgets(linestr, AU_LINE_MAX, fp) != NULL) { - /* Remove trailing new line character */ - if ((nl = strrchr(linestr, '\n')) != NULL) - *nl = '\0'; - - /* parse tokptr to au_class_ent components */ - if (classfromstr(linestr, delim, c) != NULL) { - if (!strcmp(name, c->ac_name)) { - pthread_mutex_unlock(&mutex); - return (c); - } + while ((c = getauclassent()) != NULL) { + if (strcmp(name, c->ac_name) == 0) { + pthread_mutex_unlock(&mutex); + return (c); } + free_au_class_ent(c); } - free_au_class_ent(c); pthread_mutex_unlock(&mutex); return (NULL); - } /*