*id = acl->acl_p->id;
if (archive_mstring_get_mbs(a, &acl->acl_p->name, name) != 0) {
if (errno == ENOMEM)
- __archive_errx(1, "No memory");
+ return (ARCHIVE_FATAL);
*name = NULL;
}
acl->acl_p = acl->acl_p->next;
if (r == 0 && wname != NULL)
length += wcslen(wname);
else if (r < 0 && errno == ENOMEM)
- __archive_errx(1, "No memory to generate "
- "the text version of the ACL");
+ return (NULL);
else
length += sizeof(uid_t) * 3 + 1;
length ++; /* colon */
/* Now, allocate the string and actually populate it. */
wp = acl->acl_text_w = (wchar_t *)malloc(length * sizeof(wchar_t));
if (wp == NULL)
- __archive_errx(1, "No memory to generate the text version of the ACL");
+ return (NULL);
count = 0;
if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL,
ap->permset, id);
count++;
} else if (r < 0 && errno == ENOMEM)
- __archive_errx(1, "No memory to generate "
- "the text version of the ACL");
+ return (NULL);
ap = ap->next;
}
}
wname, ap->permset, id);
count ++;
} else if (r < 0 && errno == ENOMEM)
- __archive_errx(1, "No memory to generate "
- "the text version of the ACL");
+ return (NULL);
ap = ap->next;
}
}
/* Now, allocate the string and actually populate it. */
p = acl->acl_text = (char *)malloc(length);
if (p == NULL)
- __archive_errx(1, "No memory to generate the text version of the ACL");
+ return (-1);
count = 0;
if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL,
archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type,
int *permset, int *tag, int *id, const char **name)
{
- return archive_acl_next(entry->archive, &entry->acl, want_type, type, permset, tag, id, name);
+ int r;
+ r = archive_acl_next(entry->archive, &entry->acl, want_type, type,
+ permset, tag, id, name);
+ if (r == ARCHIVE_FATAL && errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (r);
}
/*
const wchar_t *
archive_entry_acl_text_w(struct archive_entry *entry, int flags)
{
- return archive_acl_text_w(entry->archive, &entry->acl, flags);
+ const wchar_t *r;
+ r = archive_acl_text_w(entry->archive, &entry->acl, flags);
+ if (r == NULL && errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (r);
}
const char *
const char *p;
if (archive_acl_text_l(&entry->acl, flags, &p, NULL, NULL) != 0
&& errno == ENOMEM)
- return (NULL);
+ __archive_errx(1, "No memory");
return (p);
}
acl_t acl;
acl_entry_t acl_entry;
acl_permset_t acl_permset;
- int ret;
+ int ret, r;
int ae_type, ae_permset, ae_tag, ae_id;
uid_t ae_uid;
gid_t ae_gid;
if (entries == 0)
return (ARCHIVE_OK);
acl = acl_init(entries);
- while (archive_acl_next(&a->archive, abstract_acl,
+ while ((r = archive_acl_next(&a->archive, abstract_acl,
ae_requested_type, &ae_type, &ae_permset, &ae_tag, &ae_id,
- &ae_name) == ARCHIVE_OK) {
+ &ae_name)) == ARCHIVE_OK) {
acl_create_entry(&acl, &acl_entry);
switch (ae_tag) {
if (ae_permset & ARCHIVE_ENTRY_ACL_READ)
acl_add_perm(acl_permset, ACL_READ);
}
+ if (r == ARCHIVE_FATAL) {
+ acl_free(acl);
+ archive_set_error(&a->archive, errno,
+ "Failed to archive_acl_next");
+ return (r);
+ }
/* Try restoring the ACL through 'fd' if we can. */
#if HAVE_ACL_SET_FD