From 56c1be44b5f77b067994a6f8f6ef2b397d7acadc Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 4 Jul 2019 12:45:44 +0200 Subject: Fix composition order of prefix + name for ustar Signed-off-by: David Oberhollenzer --- lib/tar/read_header.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c index 1506037..db40d7d 100644 --- a/lib/tar/read_header.c +++ b/lib/tar/read_header.c @@ -212,10 +212,9 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax, out->name = malloc(len1 + 1 + len2 + 1); if (out->name != NULL) { - memcpy(out->name, hdr->name, len1); - out->name[len1] = '/'; - memcpy(out->name + len1 + 1, - hdr->tail.posix.prefix, len2); + memcpy(out->name, hdr->tail.posix.prefix, len2); + out->name[len2] = '/'; + memcpy(out->name + len2 + 1, hdr->name, len1); out->name[len1 + 1 + len2] = '\0'; } } else { -- cgit v1.2.3