PERFORCE change 87517 for review
Robert Watson
rwatson at FreeBSD.org
Wed Nov 30 14:02:56 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=87517
Change 87517 by rwatson at rwatson_peppercorn on 2005/11/30 14:01:59
Fix additional bugs in reading of audit_control: return (-2) when
errno will have a valid error number for the caller. Properly
iterate over the file, correcting bugs introduced in the previous
revision.
Affected files ...
.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#7 edit
Differences ...
==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#7 (text+ko) ====
@@ -65,7 +65,7 @@
if ((fp == NULL) && ((fp = fopen(AUDIT_CONTROL_FILE, "r")) ==
NULL)) {
pthread_mutex_unlock(&mutex);
- return (0); /* Error */
+ return (-1); /* Error */
}
while (1) {
@@ -73,28 +73,29 @@
pthread_mutex_unlock(&mutex);
if (ferror(fp))
return (-1);
- return (0);
+ return (0); /* EOF */
}
- if (linestr[0] != '#')
- break;
- }
+ if (linestr[0] == '#')
+ continue;
+
- /* Remove trailing new line character. */
- if ((nl = strrchr(linestr, '\n')) != NULL)
- *nl = '\0';
+ /* 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) {
- errno = EINVAL;
- return (-1); /* Parse error in file */
+ tokptr = linestr;
+ if ((type = strtok_r(tokptr, delim, &last)) != NULL) {
+ if (strcmp(name, type) == 0) {
+ /* 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 */
}
- return (0); /* Success */
}
}
@@ -162,7 +163,7 @@
pthread_mutex_unlock(&mutex);
if (getstrfromtype(DIR_CONTROL_ENTRY, &dir) < 0)
- return (-3);
+ return (-2);
if (dir == NULL)
return (-1);
@@ -191,7 +192,7 @@
}
if (getstrfromtype(MINFREE_CONTROL_ENTRY, &min) < 0)
- return (-3);
+ return (-2);
if (min == NULL)
return (1);
@@ -217,7 +218,7 @@
}
if (getstrfromtype(FLAGS_CONTROL_ENTRY, &str) < 0)
- return (-3);
+ return (-2);
if (str == NULL)
return (1);
@@ -246,7 +247,7 @@
}
if (getstrfromtype(NA_CONTROL_ENTRY, &str) < 0)
- return (-3);
+ return (-2);
if (str == NULL)
return (1);
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