PERFORCE change 87394 for review
Robert Watson
rwatson at FreeBSD.org
Mon Nov 28 23:58:22 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=87394
Change 87394 by rwatson at rwatson_peppercorn on 2005/11/28 23:57:55
Apply similar changes to audit_control parsing as previously
applied to audit_class: handle comments without terminating
parsing, universally use (-1) as the return value for errors.
Distinguish EOF and an error reading a configuration file.
Affected files ...
.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#6 edit
Differences ...
==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#6 (text+ko) ====
@@ -68,22 +68,33 @@
return (0); /* Error */
}
- /* Search for the line beginning with the given name. */
- while (fgets(linestr, AU_LINE_MAX, fp) != NULL) {
- /* Remove trailing new line character. */
- if ((nl = strrchr(linestr, '\n')) != NULL)
- *nl = '\0';
+ while (1) {
+ if (fgets(linestr, AU_LINE_MAX, fp) == NULL) {
+ pthread_mutex_unlock(&mutex);
+ if (ferror(fp))
+ return (-1);
+ return (0);
+ }
+
+ if (linestr[0] != '#')
+ break;
+ }
+
+ /* Remove trailing new line character. */
+ if ((nl = strrchr(linestr, '\n')) != NULL)
+ *nl = '\0';
- tokptr = linestr;
- if ((type = strtok_r(tokptr, delim, &last)) != NULL) {
- if (!strcmp(name, type)) {
- /* Found matching name. */
- *str = strtok_r(NULL, delim, &last);
- pthread_mutex_unlock(&mutex);
- if (*str == NULL)
- return (1); /* Parse error in file */
- return (0); /* Success */
+ tokptr = linestr;
+ if ((type = strtok_r(tokptr, delim, &last)) != NULL) {
+ if (!strcmp(name, type)) {
+ /* Found matching name. */
+ *str = strtok_r(NULL, delim, &last);
+ pthread_mutex_unlock(&mutex);
+ if (*str == NULL) {
+ errno = EINVAL;
+ return (-1); /* Parse error in file */
}
+ return (0); /* Success */
}
}
@@ -150,7 +161,7 @@
pthread_mutex_unlock(&mutex);
- if (getstrfromtype(DIR_CONTROL_ENTRY, &dir) == 1)
+ if (getstrfromtype(DIR_CONTROL_ENTRY, &dir) < 0)
return (-3);
if (dir == NULL)
@@ -179,7 +190,7 @@
return (-2);
}
- if (getstrfromtype(MINFREE_CONTROL_ENTRY, &min) == 1)
+ if (getstrfromtype(MINFREE_CONTROL_ENTRY, &min) < 0)
return (-3);
if (min == NULL)
@@ -205,7 +216,7 @@
return (-2);
}
- if (getstrfromtype(FLAGS_CONTROL_ENTRY, &str) == 1)
+ if (getstrfromtype(FLAGS_CONTROL_ENTRY, &str) < 0)
return (-3);
if (str == NULL)
@@ -234,7 +245,7 @@
return (-2);
}
- if (getstrfromtype(NA_CONTROL_ENTRY, &str) == 1)
+ if (getstrfromtype(NA_CONTROL_ENTRY, &str) < 0)
return (-3);
if (str == 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