summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-06-26 14:29:29 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-06-26 14:29:29 +0300
commit677d3240a845833dfb5c76491c0fd05efb934b2b (patch)
treedefc648aaf5b5a7869d0d8ba5da58331a8020a41
parent51ec463e9d9b5e5c20e1e476870b19f14f856456 (diff)
downloadapk-tools-677d3240a845833dfb5c76491c0fd05efb934b2b.tar.gz
apk-tools-677d3240a845833dfb5c76491c0fd05efb934b2b.tar.bz2
apk-tools-677d3240a845833dfb5c76491c0fd05efb934b2b.tar.xz
apk-tools-677d3240a845833dfb5c76491c0fd05efb934b2b.zip
tar: use standard header prefix
APKs have been created with GNU tar so far, which uses the GNU extensions for long names. In order to increase portability support the standard header's 'prefix' portion in case the GNU extensions are not present.
-rw-r--r--src/archive.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/archive.c b/src/archive.c
index 438eb94..b1f9c30 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -206,10 +206,12 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
int end = 0, r;
size_t toskip, paxlen = 0;
apk_blob_t pax = APK_BLOB_NULL, longname = APK_BLOB_NULL;
+ char filename[sizeof buf.name + sizeof buf.prefix + 2];
odi = (struct apk_tar_digest_info *) &buf.linkname[3];
EVP_MD_CTX_init(&teis.mdctx);
memset(&entry, 0, sizeof(entry));
+ entry.name = buf.name;
while ((r = apk_istream_read(is, &buf, 512)) == 512) {
offset += 512;
if (buf.name[0] == '\0') {
@@ -224,13 +226,19 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
.gid = apk_resolve_gid(idc, buf.gname, GET_OCTAL(buf.gid)),
.mode = GET_OCTAL(buf.mode) & 07777,
.mtime = GET_OCTAL(buf.mtime),
- .name = entry.name ?: buf.name,
+ .name = entry.name,
.uname = buf.uname,
.gname = buf.gname,
.device = makedev(GET_OCTAL(buf.devmajor),
GET_OCTAL(buf.devminor)),
.xattrs = entry.xattrs,
};
+ if (buf.prefix[0] && buf.typeflag != 'x' && buf.typeflag != 'g') {
+ snprintf(filename, sizeof filename, "%.*s/%.*s",
+ (int) sizeof buf.prefix, buf.prefix,
+ (int) sizeof buf.name, buf.name);
+ entry.name = filename;
+ }
buf.mode[0] = 0; /* to nul terminate 100-byte buf.name */
buf.magic[0] = 0; /* to nul terminate 100-byte buf.linkname */
teis.csum = NULL;