Fix creation of symlinks to files with long names (greater than 100 chars).
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 4 Aug 2010 00:45:57 +0000 (00:45 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 4 Aug 2010 00:45:57 +0000 (00:45 +0000)
From "paradox.kahn", see Issue #55.

git-svn-id: http://opkg.googlecode.com/svn/trunk@544 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libbb/unarchive.c

index bf57a04777c126be7c8a473bf284d9eea30f5f8e..b063c6335a0889155e1f45d6cad71726be932f49 100644 (file)
@@ -466,7 +466,7 @@ get_header_tar(FILE *tar_stream)
        }
 
        if (fread(tar.raw, 1, 512, tar_stream) != 512) {
-               /* Unfortunatly its common for tar files to have all sorts of
+               /* Unfortunately its common for tar files to have all sorts of
                 * trailing garbage, fail silently */
 //             error_msg("Couldnt read header");
                return(NULL);
@@ -505,10 +505,6 @@ get_header_tar(FILE *tar_stream)
         if (longname) {
                 tar_entry->name = longname;
                 longname = NULL;
-        }
-        else if (linkname) {
-                tar_entry->name = linkname;
-                linkname = NULL;
         } else
 #endif
         {
@@ -534,7 +530,16 @@ get_header_tar(FILE *tar_stream)
        tar_entry->gid   = strtol(tar.formated.gid, NULL, 8);
        tar_entry->size  = strtol(tar.formated.size, NULL, 8);
        tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
-       tar_entry->link_name  = *tar.formated.linkname != '\0' ? xstrndup(tar.formated.linkname, 100) : NULL;
+#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
+       if (linkname) {
+               tar_entry->link_name = linkname;
+               linkname = NULL;
+       } else
+#endif
+       {
+               tar_entry->link_name = *tar.formated.linkname != '\0' ?
+                       xstrndup(tar.formated.linkname, 100) : NULL;
+       }
        tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) +
                strtol(tar.formated.devminor, NULL, 8);
 
@@ -586,7 +591,6 @@ get_header_tar(FILE *tar_stream)
                        linkname[tar_entry->size] = '\0';
                        archive_offset += tar_entry->size;
 
-                       tar_entry->name = linkname;
                        return(get_header_tar(tar_stream));
                }
        case 'D':