PERFORCE change 165010 for review

Stacey Son sson at FreeBSD.org
Tue Jun 23 22:39:22 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=165010

Change 165010 by sson at sson_amd64 on 2009/06/23 22:38:28

	Remove trailing white space when parsing audit_control.	
	
	Trailing white space can cause problems with some fields
	such as 'dir' in the audit_control file. Besides removing
	the trailing new line we remove the trail white space as
	well.
	
	(Credit to Brooks Davis for finding this bug.)

Affected files ...

.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#34 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#34 (text+ko) ====

@@ -27,7 +27,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#33 $
+ * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#34 $
  */
 
 #include <config/config.h>
@@ -121,9 +121,13 @@
 		if (linestr[0] == '#')
 			continue;
 
-		/* Remove trailing new line character. */
-		if ((nl = strrchr(linestr, '\n')) != NULL)
+		/* Remove trailing new line character and white space. */
+		nl = strchr(linestr, '\0') - 1;
+		while (nl >= linestr && ('\n' == *nl || ' ' == *nl ||
+			'\t' == *nl)) {
 			*nl = '\0';
+			nl--;
+		}
 
 		tokptr = linestr;
 		if ((type = strtok_r(tokptr, delim, &last)) != NULL) {


More information about the p4-projects mailing list