diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-04-06 23:16:50 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-04-06 23:16:50 +0000 |
commit | f66baeffb4a34dc9ddefcb67483fe0eeb09f56b9 (patch) | |
tree | 90b995b3e74d4ca9b699ccd90f762138f10db7b4 /lib/libarchive/archive_write_set_format_pax.c | |
parent | 3a3d909a8cb270706cd7840fed0e6a63f046e2b4 (diff) | |
download | FreeBSD-src-f66baeffb4a34dc9ddefcb67483fe0eeb09f56b9.zip FreeBSD-src-f66baeffb4a34dc9ddefcb67483fe0eeb09f56b9.tar.gz |
Fix some issues with ACL handling:
* ACL storage is no longer erased before a group of entries are added.
* ACL text creation no longer tries to skip over non-existent text.
* UTF8 encoder no longer blows up on invalid wide characters.
* Fixed ACL state management for default ACLs.
Also, publicize function for obtaining text-format ACL in various
formats. The interface is now extensible through a "flags" argument
that allows you to select a variant format.
Diffstat (limited to 'lib/libarchive/archive_write_set_format_pax.c')
-rw-r--r-- | lib/libarchive/archive_write_set_format_pax.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/libarchive/archive_write_set_format_pax.c b/lib/libarchive/archive_write_set_format_pax.c index d0cec2c..ab060fd 100644 --- a/lib/libarchive/archive_write_set_format_pax.c +++ b/lib/libarchive/archive_write_set_format_pax.c @@ -197,7 +197,9 @@ add_pax_attr_w(struct archive_string *as, const char *key, const wchar_t *wval) utf8len = 0; for (wp = wval; *wp != L'\0'; ) { wc = *wp++; - if (wc <= 0x7f) + if (wc <= 0) { + /* Ignore negative values. */ + } else if (wc <= 0x7f) utf8len++; else if (wc <= 0x7ff) utf8len += 2; @@ -214,7 +216,9 @@ add_pax_attr_w(struct archive_string *as, const char *key, const wchar_t *wval) utf8_value = malloc(utf8len + 1); for (wp = wval, p = utf8_value; *wp != L'\0'; ) { wc = *wp++; - if (wc <= 0x7f) { + if (wc <= 0) { + /* Ignore negative values. */ + } else if (wc <= 0x7f) { *p++ = (char)wc; } else if (wc <= 0x7ff) { p[0] = 0xc0 | ((wc >> 6) & 0x1f); @@ -485,16 +489,17 @@ archive_write_pax_header(struct archive *a, * avoid writing an mtime attribute just to handle a * high-resolution timestamp in "restricted pax" mode. */ - if ((st_main->st_mtime < 0) || (st_main->st_mtime >= 0x7fffffff)) + if (!need_extension && + ((st_main->st_mtime < 0) || (st_main->st_mtime >= 0x7fffffff))) need_extension = 1; /* If there are non-trivial ACL entries, we need an extension. */ - if (archive_entry_acl_count(entry_original, + if (!need_extension && archive_entry_acl_count(entry_original, ARCHIVE_ENTRY_ACL_TYPE_ACCESS) > 0) need_extension = 1; /* If there are non-trivial ACL entries, we need an extension. */ - if (archive_entry_acl_count(entry_original, + if (!need_extension && archive_entry_acl_count(entry_original, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) > 0) need_extension = 1; @@ -530,15 +535,18 @@ archive_write_pax_header(struct archive *a, add_pax_attr(&(pax->pax_header), "SCHILY.fflags", p); /* I use star-compatible ACL attributes. */ - wp = __archive_entry_acl_text_w(entry_original, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS); + wp = archive_entry_acl_text_w(entry_original, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS | + ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID); if (wp != NULL && *wp != L'\0') - add_pax_attr_w(&(pax->pax_header), "SCHILY.acl.access", wp); - wp = __archive_entry_acl_text_w(entry_original, - ARCHIVE_ENTRY_ACL_TYPE_DEFAULT); + add_pax_attr_w(&(pax->pax_header), + "SCHILY.acl.access", wp); + wp = archive_entry_acl_text_w(entry_original, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT | + ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID); if (wp != NULL && *wp != L'\0') - add_pax_attr_w(&(pax->pax_header), "SCHILY.acl.default", - wp); + add_pax_attr_w(&(pax->pax_header), + "SCHILY.acl.default", wp); /* Include star-compatible metadata info. */ add_pax_attr_int(&(pax->pax_header), "SCHILY.dev", |