Am 21.06.2016 um 22:42 schrieb René Scharfe: > The value 120 is magic; we need it to pass the tests. That's > because prepare_header() is used for building extended header > records as well and we don't create extended headers for extended > headers (not sure if that would work anyway), so they simply > vanish when they're over the limit as their size field is set to > zero. So how about something like this to make sure extended headers are only written for regular files and not for other extended headers? --- archive-tar.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/archive-tar.c b/archive-tar.c index ed562d4..f53e61c 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -199,7 +199,7 @@ static void prepare_header(struct archiver_args *args, { xsnprintf(header->mode, sizeof(header->mode), "%07o", mode & 07777); xsnprintf(header->size, sizeof(header->size), "%011lo", - S_ISREG(mode) ? ustar_size(size) : 0); + S_ISREG(mode) ? size : 0); xsnprintf(header->mtime, sizeof(header->mtime), "%011lo", ustar_mtime(args->time)); @@ -240,7 +240,7 @@ static int write_tar_entry(struct archiver_args *args, struct ustar_header header; struct strbuf ext_header = STRBUF_INIT; unsigned int old_mode = mode; - unsigned long size; + unsigned long size, size_in_header; void *buffer; int err = 0; @@ -299,12 +299,14 @@ static int write_tar_entry(struct archiver_args *args, memcpy(header.linkname, buffer, size); } - if (S_ISREG(mode) && ustar_size(size) != size) + size_in_header = S_ISREG(mode) ? ustar_size(size) : size; + if (size_in_header != size) strbuf_append_ext_header_uint(&ext_header, "size", size); + if (ustar_mtime(args->time) != args->time) strbuf_append_ext_header_uint(&ext_header, "mtime", args->time); - prepare_header(args, &header, mode, size); + prepare_header(args, &header, mode, size_in_header); if (ext_header.len > 0) { err = write_extended_header(args, sha1, ext_header.buf, -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html