From c6b235629a180c66e5960a533b51f9df180f5d60 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Fri, 6 Mar 2009 04:21:23 +0000 Subject: [PATCH] Merge r394,r396 from libarchive.googlecode.com: Plug some memory leaks in the ACL test, correctly mark that FreeBSD has acl_get_perm_np(). --- lib/libarchive/config_freebsd.h | 1 + lib/libarchive/test/test_acl_freebsd.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h index a11b0b858ffe..aa3aba9a9d88 100644 --- a/lib/libarchive/config_freebsd.h +++ b/lib/libarchive/config_freebsd.h @@ -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 diff --git a/lib/libarchive/test/test_acl_freebsd.c b/lib/libarchive/test/test_acl_freebsd.c index 59481fc3adeb..88efb191c48f 100644 --- a/lib/libarchive/test/test_acl_freebsd.c +++ b/lib/libarchive/test/test_acl_freebsd.c @@ -72,6 +72,8 @@ set_acls(struct archive_entry *ae, struct myacl_t *acls) 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 myacl_t *myacl) 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 myacl_t *myacl) 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 }