diff options
Diffstat (limited to 'lib/tar/src')
-rw-r--r-- | lib/tar/src/cleanup.c | 3 | ||||
-rw-r--r-- | lib/tar/src/iterator.c | 5 | ||||
-rw-r--r-- | lib/tar/src/pax_header.c | 26 | ||||
-rw-r--r-- | lib/tar/src/write_header.c | 10 |
4 files changed, 23 insertions, 21 deletions
diff --git a/lib/tar/src/cleanup.c b/lib/tar/src/cleanup.c index 3ba8019..145f34d 100644 --- a/lib/tar/src/cleanup.c +++ b/lib/tar/src/cleanup.c @@ -7,6 +7,7 @@ #include "config.h" #include "internal.h" +#include "sqfs/xattr.h" #include <stdlib.h> #include <string.h> @@ -23,7 +24,7 @@ void free_sparse_list(sparse_map_t *sparse) void clear_header(tar_header_decoded_t *hdr) { - dir_entry_xattr_list_free(hdr->xattr); + sqfs_xattr_list_free(hdr->xattr); free_sparse_list(hdr->sparse); free(hdr->name); free(hdr->link_target); diff --git a/lib/tar/src/iterator.c b/lib/tar/src/iterator.c index b1be42d..216c528 100644 --- a/lib/tar/src/iterator.c +++ b/lib/tar/src/iterator.c @@ -6,6 +6,7 @@ */ #include "tar/tar.h" #include "sqfs/error.h" +#include "sqfs/xattr.h" #include "util/util.h" #include <stdlib.h> @@ -281,7 +282,7 @@ static int it_open_file_ro(dir_iterator_t *it, istream_t **out) return 0; } -static int it_read_xattr(dir_iterator_t *it, dir_entry_xattr_t **out) +static int it_read_xattr(dir_iterator_t *it, sqfs_xattr_t **out) { tar_iterator_t *tar = (tar_iterator_t *)it; @@ -293,7 +294,7 @@ static int it_read_xattr(dir_iterator_t *it, dir_entry_xattr_t **out) return tar->state < 0 ? tar->state : SQFS_ERROR_NO_ENTRY; if (tar->current.xattr != NULL) { - *out = dir_entry_xattr_list_copy(tar->current.xattr); + *out = sqfs_xattr_list_copy(tar->current.xattr); if (*out == NULL) return SQFS_ERROR_ALLOC; } diff --git a/lib/tar/src/pax_header.c b/lib/tar/src/pax_header.c index 81f6ad4..74a1b24 100644 --- a/lib/tar/src/pax_header.c +++ b/lib/tar/src/pax_header.c @@ -7,6 +7,7 @@ #include "config.h" #include "internal.h" +#include "sqfs/xattr.h" #include <ctype.h> #include <string.h> #include <stdlib.h> @@ -140,27 +141,27 @@ fail: return -1; } -static int pax_xattr_schily(tar_header_decoded_t *out, - dir_entry_xattr_t *xattr) +static int pax_xattr_schily(tar_header_decoded_t *out, sqfs_xattr_t *xattr) { xattr->next = out->xattr; out->xattr = xattr; return 0; } -static int pax_xattr_libarchive(tar_header_decoded_t *out, - dir_entry_xattr_t *xattr) +static int pax_xattr_libarchive(tar_header_decoded_t *out, sqfs_xattr_t *xattr) { + char *key = (char *)xattr->data; + sqfs_u8 *value = xattr->data + (size_t)(xattr->value - xattr->data); int ret; ret = base64_decode((const char *)xattr->value, xattr->value_len, - xattr->value, &xattr->value_len); + value, &xattr->value_len); if (ret) return -1; - urldecode(xattr->key); + urldecode(key); + value[xattr->value_len] = '\0'; - xattr->value[xattr->value_len] = '\0'; xattr->next = out->xattr; out->xattr = xattr; return 0; @@ -184,8 +185,7 @@ static const struct pax_handler_t { int (*uint)(tar_header_decoded_t *out, sqfs_u64 uval); int (*str)(tar_header_decoded_t *out, char *str); int (*cstr)(tar_header_decoded_t *out, const char *str); - int (*xattr)(tar_header_decoded_t *out, - dir_entry_xattr_t *xattr); + int (*xattr)(tar_header_decoded_t *out, sqfs_xattr_t *xattr); } cb; } pax_fields[] = { { "uid", PAX_UID, PAX_TYPE_UINT, { .uint = pax_uid } }, @@ -239,7 +239,7 @@ static int apply_handler(tar_header_decoded_t *out, const struct pax_handler_t *field, const char *key, const char *value, size_t valuelen) { - dir_entry_xattr_t *xattr; + sqfs_xattr_t *xattr; sqfs_s64 s64val; sqfs_u64 uval; char *copy; @@ -274,9 +274,9 @@ static int apply_handler(tar_header_decoded_t *out, } break; case PAX_TYPE_PREFIXED_XATTR: - xattr = dir_entry_xattr_create(key + strlen(field->name) + 1, - (const sqfs_u8 *)value, - valuelen); + xattr = sqfs_xattr_create(key + strlen(field->name) + 1, + (const sqfs_u8 *)value, + valuelen); if (xattr == NULL) { perror("reading pax xattr field"); return -1; diff --git a/lib/tar/src/write_header.c b/lib/tar/src/write_header.c index f5473ca..039d1fe 100644 --- a/lib/tar/src/write_header.c +++ b/lib/tar/src/write_header.c @@ -7,6 +7,7 @@ #include "config.h" #include "internal.h" +#include "sqfs/xattr.h" #include <string.h> #include <stdlib.h> @@ -144,15 +145,14 @@ static size_t prefix_digit_len(size_t len) } static int write_schily_xattr(ostream_t *fp, const struct stat *orig, - const char *name, const dir_entry_xattr_t *xattr) + const char *name, const sqfs_xattr_t *xattr) { static const char *prefix = "SCHILY.xattr."; size_t len, total_size = 0; - const dir_entry_xattr_t *it; char *buffer, *ptr; int ret; - for (it = xattr; it != NULL; it = it->next) { + for (const sqfs_xattr_t *it = xattr; it != NULL; it = it->next) { len = strlen(prefix) + strlen(it->key) + it->value_len + 3; total_size += len + prefix_digit_len(len); @@ -167,7 +167,7 @@ static int write_schily_xattr(ostream_t *fp, const struct stat *orig, ptr = buffer; - for (it = xattr; it != NULL; it = it->next) { + for (const sqfs_xattr_t *it = xattr; it != NULL; it = it->next) { len = strlen(prefix) + strlen(it->key) + it->value_len + 3; len += prefix_digit_len(len); @@ -184,7 +184,7 @@ static int write_schily_xattr(ostream_t *fp, const struct stat *orig, } int write_tar_header(ostream_t *fp, const struct stat *sb, const char *name, - const char *slink_target, const dir_entry_xattr_t *xattr, + const char *slink_target, const sqfs_xattr_t *xattr, unsigned int counter) { const char *reason; |