diff options
Diffstat (limited to 'contrib/libarchive/libarchive/archive_acl.c')
-rw-r--r-- | contrib/libarchive/libarchive/archive_acl.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/contrib/libarchive/libarchive/archive_acl.c b/contrib/libarchive/libarchive/archive_acl.c index fbf029894436..bf4b61040ef6 100644 --- a/contrib/libarchive/libarchive/archive_acl.c +++ b/contrib/libarchive/libarchive/archive_acl.c @@ -422,8 +422,11 @@ archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type, int *permset = acl->acl_p->permset; *tag = acl->acl_p->tag; *id = acl->acl_p->id; - if (archive_mstring_get_mbs(a, &acl->acl_p->name, name) != 0) + if (archive_mstring_get_mbs(a, &acl->acl_p->name, name) != 0) { + if (errno == ENOMEM) + return (ARCHIVE_FATAL); *name = NULL; + } acl->acl_p = acl->acl_p->next; return (ARCHIVE_OK); } @@ -441,7 +444,7 @@ archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags) const wchar_t *prefix; wchar_t separator; struct archive_acl_entry *ap; - int id; + int id, r; wchar_t *wp; if (acl->acl_text_w != NULL) { @@ -461,9 +464,11 @@ archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags) length += 8; /* "default:" */ length += 5; /* tag name */ length += 1; /* colon */ - if (archive_mstring_get_wcs(a, &ap->name, &wname) == 0 && - wname != NULL) + r = archive_mstring_get_wcs(a, &ap->name, &wname); + if (r == 0 && wname != NULL) length += wcslen(wname); + else if (r < 0 && errno == ENOMEM) + return (NULL); else length += sizeof(uid_t) * 3 + 1; length ++; /* colon */ @@ -487,7 +492,7 @@ archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags) /* 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, @@ -502,16 +507,19 @@ archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags) ap = acl->acl_head; while (ap != NULL) { - if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0 && - archive_mstring_get_wcs(a, &ap->name, &wname) == 0) { - *wp++ = separator; - if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) - id = ap->id; - else - id = -1; - append_entry_w(&wp, NULL, ap->tag, wname, - ap->permset, id); - count++; + if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { + r = archive_mstring_get_wcs(a, &ap->name, &wname); + if (r == 0) { + *wp++ = separator; + if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) + id = ap->id; + else + id = -1; + append_entry_w(&wp, NULL, ap->tag, wname, + ap->permset, id); + count++; + } else if (r < 0 && errno == ENOMEM) + return (NULL); } ap = ap->next; } @@ -526,17 +534,20 @@ archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags) ap = acl->acl_head; count = 0; while (ap != NULL) { - if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0 && - archive_mstring_get_wcs(a, &ap->name, &wname) == 0) { - if (count > 0) - *wp++ = separator; - if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) - id = ap->id; - else - id = -1; - append_entry_w(&wp, prefix, ap->tag, - wname, ap->permset, id); - count ++; + if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) { + r = archive_mstring_get_wcs(a, &ap->name, &wname); + if (r == 0) { + if (count > 0) + *wp++ = separator; + if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) + id = ap->id; + else + id = -1; + append_entry_w(&wp, prefix, ap->tag, + wname, ap->permset, id); + count ++; + } else if (r < 0 && errno == ENOMEM) + return (NULL); } ap = ap->next; } @@ -675,7 +686,7 @@ archive_acl_text_l(struct archive_acl *acl, int flags, /* 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, |