Fix long filename support

This commit is contained in:
Glenn L McGrath 2002-11-23 10:44:47 +00:00
parent 1b16bf6b1b
commit b7a76df4d1

View File

@ -20,6 +20,11 @@
#include "unarchive.h" #include "unarchive.h"
#include "libbb.h" #include "libbb.h"
#ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME
static char *longname = NULL;
static char *linkname = NULL;
#endif
extern char get_header_tar(archive_handle_t *archive_handle) extern char get_header_tar(archive_handle_t *archive_handle)
{ {
file_header_t *file_header = archive_handle->file_header; file_header_t *file_header = archive_handle->file_header;
@ -85,7 +90,16 @@ extern char get_header_tar(archive_handle_t *archive_handle)
return(EXIT_FAILURE); return(EXIT_FAILURE);
} }
/* convert to type'ed variables */ #ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME
if (longname) {
file_header->name = longname;
longname = NULL;
}
else if (linkname) {
file_header->name = linkname;
linkname = NULL;
} else
#endif
if (tar.formated.prefix[0] == 0) { if (tar.formated.prefix[0] == 0) {
file_header->name = strdup(tar.formated.name); file_header->name = strdup(tar.formated.name);
} else { } else {
@ -134,28 +148,21 @@ extern char get_header_tar(archive_handle_t *archive_handle)
# endif # endif
# ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME # ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME
case 'L': { case 'L': {
char *longname;
longname = xmalloc(file_header->size + 1); longname = xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, longname, file_header->size); archive_xread_all(archive_handle, longname, file_header->size);
longname[file_header->size] = '\0'; longname[file_header->size] = '\0';
archive_handle->offset += file_header->size; archive_handle->offset += file_header->size;
get_header_tar(archive_handle); return(get_header_tar(archive_handle));
file_header->name = longname;
break;
} }
case 'K': { case 'K': {
char *linkname;
linkname = xmalloc(file_header->size + 1); linkname = xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, linkname, file_header->size); archive_xread_all(archive_handle, linkname, file_header->size);
linkname[file_header->size] = '\0'; linkname[file_header->size] = '\0';
archive_handle->offset += file_header->size; archive_handle->offset += file_header->size;
get_header_tar(archive_handle);
file_header->name = linkname; file_header->name = linkname;
break; return(get_header_tar(archive_handle));
} }
# endif # endif
} }