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

aalvarez at FreeBSD.org aalvarez at FreeBSD.org
Thu Jun 16 18:21:43 UTC 2011


Author: aalvarez
Date: Thu Jun 16 18:21:41 2011
New Revision: 223304
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=223304

Log:
  Free memory allocated for filepath

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

Modified: soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.c
==============================================================================
--- soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.c	Thu Jun 16 17:41:21 2011	(r223303)
+++ soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.c	Thu Jun 16 18:21:41 2011	(r223304)
@@ -172,7 +172,7 @@
 out:
 	NDFREE(&nd, 0);
 	if (error)
-		free(ruleptr->mbr_object.mbo_fpath, M_MACBSDEXTENDED);
+		KMBRFREE((*ruleptr), M_MACBSDEXTENDED);
 
 	return error;
 }
@@ -203,7 +203,7 @@
 	}
 
 	mtx_lock(&ugidfw_mtx);
-	if (req->oldptr) {
+	if (req->oldptr) { /* Modify rule request */
 		if (index < 0 || index > rule_slots + 1) {
 			error = ENOENT;
 			goto out;
@@ -229,7 +229,7 @@
 			goto out;
 		if (rules[index] == NULL) {
 			*ruleptr = temprule;
-			if (ruleptr->mbr_object.mbo_flags & MBO_FSID_DEFINED) {
+			if (ruleptr->mbr_object.mbo_flags & MBO_FPATH_DEFINED) {
 				error = ugidfw_rslv_fpath(ruleptr, &temprule, req->td);
 				if (error)
 					goto out;
@@ -267,8 +267,10 @@
 	int i;
 
 	for (i = 0; i < MAC_BSDEXTENDED_MAXRULES; i++) {
-		if (rules[i] != NULL)
+		if (rules[i] != NULL) {
+			KMBRFREE((*rules[i]), M_MACBSDEXTENDED);
 			free(rules[i], M_MACBSDEXTENDED);
+		}
 	}
 	mtx_destroy(&ugidfw_mtx);
 }

Modified: soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.h
==============================================================================
--- soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.h	Thu Jun 16 17:41:21 2011	(r223303)
+++ soc2011/aalvarez/pbmac/sys/security/mac_bsdextended/mac_bsdextended.h	Thu Jun 16 18:21:41 2011	(r223304)
@@ -115,4 +115,8 @@
 	mode_t				mbr_mode;	/* maximum access */
 };
 
+#define MBRINIT(rule) bzero(rule, sizeof(*rule))
+#define MBRFREE(rule) if (rule.mbr_object.mbo_fpath != NULL) free(rule.mbr_object.mbo_fpath)
+#define KMBRFREE(rule, malloctype) if (rule.mbr_object.mbo_fpath != NULL) free(rule.mbr_object.mbo_fpath, malloctype)
+
 #endif /* _SYS_SECURITY_MAC_BSDEXTENDED_H */


More information about the svn-soc-all mailing list