X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Flist.c;h=7a9bd5079b4f0dc5da34fe208e4f7e3034c8f153;hb=e1ac06bccae865dc1cd7266302961a0ff68716b3;hp=2eba9f651fb8a650db9a43d511c414b938a72169;hpb=53a5ac41d2847fd12f9ad894898f2e77299abeee;p=chaz%2Ftar diff --git a/src/list.c b/src/list.c index 2eba9f6..7a9bd50 100644 --- a/src/list.c +++ b/src/list.c @@ -415,9 +415,28 @@ read_header (void) } else { - assign_string (¤t_file_name, - (next_long_name ? next_long_name - : current_header->header.name)); + char *name = next_long_name; + struct posix_header *h = ¤t_header->header; + char namebuf[sizeof h->prefix + 1 + sizeof h->name + 1]; + + if (! name) + { + /* Accept file names as specified by POSIX.1-1996 + section 10.1.1. */ + char *np = namebuf; + if (h->prefix[0]) + { + memcpy (np, h->prefix, sizeof h->prefix); + np[sizeof h->prefix] = '\0'; + np += strlen (np); + *np++ = '/'; + } + memcpy (np, h->name, sizeof h->name); + np[sizeof h->name] = '\0'; + name = namebuf; + } + + assign_string (¤t_file_name, name); assign_string (¤t_link_name, (next_long_link ? next_long_link : current_header->header.linkname));