svn commit: r189427 - in head/lib/libarchive: . test

Tim Kientzle kientzle at FreeBSD.org
Thu Mar 5 20:21:24 PST 2009


Author: kientzle
Date: Fri Mar  6 04:21:23 2009
New Revision: 189427
URL: http://svn.freebsd.org/changeset/base/189427

Log:
  Merge r394,r396 from libarchive.googlecode.com: Plug some memory
  leaks in the ACL test, correctly mark that FreeBSD has acl_get_perm_np().

Modified:
  head/lib/libarchive/config_freebsd.h
  head/lib/libarchive/test/test_acl_freebsd.c

Modified: head/lib/libarchive/config_freebsd.h
==============================================================================
--- head/lib/libarchive/config_freebsd.h	Fri Mar  6 01:34:30 2009	(r189426)
+++ head/lib/libarchive/config_freebsd.h	Fri Mar  6 04:21:23 2009	(r189427)
@@ -28,6 +28,7 @@
 /* FreeBSD 5.0 and later have ACL support. */
 #if __FreeBSD__ > 4
 #define	HAVE_ACL_CREATE_ENTRY 1
+#define	HAVE_ACL_GET_PERM_NP 1
 #define	HAVE_ACL_INIT 1
 #define	HAVE_ACL_SET_FD 1
 #define	HAVE_ACL_SET_FD_NP 1

Modified: head/lib/libarchive/test/test_acl_freebsd.c
==============================================================================
--- head/lib/libarchive/test/test_acl_freebsd.c	Fri Mar  6 01:34:30 2009	(r189426)
+++ head/lib/libarchive/test/test_acl_freebsd.c	Fri Mar  6 04:21:23 2009	(r189427)
@@ -72,6 +72,8 @@ set_acls(struct archive_entry *ae, struc
 static int
 acl_match(acl_entry_t aclent, struct myacl_t *myacl)
 {
+	gid_t g, *gp;
+	uid_t u, *up;
 	acl_tag_t tag_type;
 	acl_permset_t opaque_ps;
 	int permset = 0;
@@ -97,7 +99,10 @@ acl_match(acl_entry_t aclent, struct mya
 	case ACL_USER:
 		if (myacl->tag != ARCHIVE_ENTRY_ACL_USER)
 			return (0);
-		if ((uid_t)myacl->qual != *(uid_t *)acl_get_qualifier(aclent))
+		up = acl_get_qualifier(aclent);
+		u = *up;
+		acl_free(up);
+		if ((uid_t)myacl->qual != u)
 			return (0);
 		break;
 	case ACL_GROUP_OBJ:
@@ -106,7 +111,10 @@ acl_match(acl_entry_t aclent, struct mya
 	case ACL_GROUP:
 		if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP)
 			return (0);
-		if ((gid_t)myacl->qual != *(gid_t *)acl_get_qualifier(aclent))
+		gp = acl_get_qualifier(aclent);
+		g = *gp;
+		acl_free(gp);
+		if ((gid_t)myacl->qual != g)
 			return (0);
 		break;
 	case ACL_MASK:
@@ -200,10 +208,13 @@ DEFINE_TEST(test_acl_freebsd)
 	/* Create a test file and try to set an ACL on it. */
 	fd = open("pretest", O_WRONLY | O_CREAT | O_EXCL, 0777);
 	failure("Could not create test file?!");
-	if (!assert(fd >= 0))
+	if (!assert(fd >= 0)) {
+		acl_free(acl);
 		return;
+	}
 
 	n = acl_set_fd(fd, acl);
+	acl_free(acl);
 	if (n != 0 && errno == EOPNOTSUPP) {
 		close(fd);
 		skipping("ACL tests require that ACL support be enabled on the filesystem");
@@ -239,5 +250,6 @@ DEFINE_TEST(test_acl_freebsd)
 	acl = acl_get_file("test0", ACL_TYPE_ACCESS);
 	assert(acl != (acl_t)NULL);
 	compare_acls(acl, acls2);
+	acl_free(acl);
 #endif
 }


More information about the svn-src-head mailing list