Fix opkg doesn't handle long link/path names in tar files well
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 21 Sep 2009 10:11:52 +0000 (10:11 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 21 Sep 2009 10:11:52 +0000 (10:11 +0000)
1. provide opkg with a tar file that has a link name that is 100
characters
    or
2. provide opkg with a tar file that has a 'path_prefix' of 155
characters.

Thanks to pblack88@gmail.com
http://code.google.com/p/opkg/issues/detail?id=21

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

libbb/unarchive.c

index 19aabff28819557bc0206720a53d6d7266acd26b..d0896ba129ff711f5b6f10148ee90105221a39da 100644 (file)
@@ -605,8 +605,10 @@ file_header_t *get_header_tar(FILE *tar_stream)
 
                 if (tar.formated.prefix[0]) {
                         char *temp = tar_entry->name;
-                        tar_entry->name = concat_path_file(tar.formated.prefix, temp);
+                        char *prefixTemp = strndup(tar.formated.prefix, 155);
+                        tar_entry->name = concat_path_file(prefixTemp, temp);
                         free(temp);
+                        free(prefixTemp);
                 }
         }
 
@@ -621,8 +623,7 @@ file_header_t *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  = strlen(tar.formated.linkname) ? 
-           xstrdup(tar.formated.linkname) : NULL;
+       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);