PERFORCE change 87385 for review
Robert Watson
rwatson at FreeBSD.org
Mon Nov 28 22:07:02 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=87385
Change 87385 by rwatson at 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);
-
}
/*
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list