socsvn commit: r222768 - soc2011/aalvarez/pbmac/sys/security/mac_bsdextended

aalvarez at FreeBSD.org aalvarez at FreeBSD.org
Fri Jun 3 15:24:59 UTC 2011


Author: aalvarez
Date: Fri Jun  3 15:24:56 2011
New Revision: 222768
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=222768

Log:
  - Lock vnode to get vattr
  - free fpath string if there's an error
  - return error code
  

Modified:
  soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.c

Modified: soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.c
==============================================================================
--- soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.c	Fri Jun  3 14:57:38 2011	(r222767)
+++ soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.c	Fri Jun  3 15:24:56 2011	(r222768)
@@ -148,15 +148,15 @@
 		return EINVAL;
 
 	ruleptr->mbr_object.mbo_fpath_len = temprule->mbr_object.mbo_fpath_len;
-	ruleptr = malloc(sizeof(char)*ruleptr->mbr_object.mbo_fpath_len,
+	ruleptr->mbr_object.mbo_fpath = malloc(sizeof(char)*(ruleptr->mbr_object.mbo_fpath_len+1),
 	    M_MACBSDEXTENDED, M_WAITOK);
 
 	KASSERT(ruleptr == NULL, ("sysctl_rule: ruleptr != NULL"));
 	memcpy(ruleptr->mbr_object.mbo_fpath, temprule->mbr_object.mbo_fpath, 
-	    ruleptr->mbr_object.mbo_fpath_len);
+	    ruleptr->mbr_object.mbo_fpath_len+1);
 	
 	/* Resolve path to fsid and fileid */
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, ruleptr->mbr_object.mbo_fpath, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, ruleptr->mbr_object.mbo_fpath, td);
 	error = namei(&nd);
 	if (error)
 		goto out;
@@ -171,7 +171,10 @@
 
 out:
 	NDFREE(&nd, 0);
-	return (0);
+	if (error)
+		free(ruleptr->mbr_object.mbo_fpath, M_MACBSDEXTENDED);
+
+	return error;
 }
 
 static int
@@ -226,10 +229,6 @@
 			goto out;
 		if (rules[index] == NULL) {
 			*ruleptr = temprule;
-			/* TODO: Check if path is defined. 
-			 * If it is: 
-			 * - resolve path to fid
-			 */
 			if (ruleptr->mbr_object.mbo_flags & MBO_FSID_DEFINED) {
 				error = ugidfw_rslv_fpath(ruleptr, &temprule, req->td);
 				if (error)


More information about the svn-soc-all mailing list