]> Dogcows Code - chaz/tar/commitdiff
(read_header): Accept file names as specified by POSIX.1-1996 section 10.1.1.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Dec 1998 22:36:22 +0000 (22:36 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Dec 1998 22:36:22 +0000 (22:36 +0000)
src/list.c

index 2eba9f651fb8a650db9a43d511c414b938a72169..7a9bd5079b4f0dc5da34fe208e4f7e3034c8f153 100644 (file)
@@ -415,9 +415,28 @@ read_header (void)
        }
       else
        {
-         assign_string (&current_file_name,
-                        (next_long_name ? next_long_name
-                         : current_header->header.name));
+         char *name = next_long_name;
+         struct posix_header *h = &current_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 (&current_file_name, name);
          assign_string (&current_link_name,
                         (next_long_link ? next_long_link
                          : current_header->header.linkname));
This page took 0.024326 seconds and 4 git commands to generate.