summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2009-03-06 04:21:23 +0000
committerkientzle <kientzle@FreeBSD.org>2009-03-06 04:21:23 +0000
commitfad4d483cfef351a6dc745c3562e7b67b864556f (patch)
tree4af157436031b7682aaaa02e8791c10b3a5c2d50
parentbc77a8346240746144dcde0fd516c9c5bc18c02e (diff)
downloadFreeBSD-src-fad4d483cfef351a6dc745c3562e7b67b864556f.zip
FreeBSD-src-fad4d483cfef351a6dc745c3562e7b67b864556f.tar.gz
Merge r394,r396 from libarchive.googlecode.com: Plug some memory
leaks in the ACL test, correctly mark that FreeBSD has acl_get_perm_np().
-rw-r--r--lib/libarchive/config_freebsd.h1
-rw-r--r--lib/libarchive/test/test_acl_freebsd.c18
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h
index a11b0b8..aa3aba9 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 59481fc..88efb19 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
}
OpenPOWER on IntegriCloud