diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/libunarchive/get_header_tar.c | 41 | ||||
-rw-r--r-- | archival/libunarchive/header_verbose_list.c | 7 | ||||
-rw-r--r-- | archival/tar.c | 6 |
3 files changed, 26 insertions, 28 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index b5cae9f12..68f7b2b9b 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c | |||
@@ -111,25 +111,6 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
111 | bb_error_msg_and_die("invalid tar header checksum"); | 111 | bb_error_msg_and_die("invalid tar header checksum"); |
112 | } | 112 | } |
113 | 113 | ||
114 | #ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS | ||
115 | if (longname) { | ||
116 | file_header->name = longname; | ||
117 | longname = NULL; | ||
118 | } | ||
119 | else if (linkname) { | ||
120 | file_header->name = linkname; | ||
121 | linkname = NULL; | ||
122 | } else | ||
123 | #endif | ||
124 | { | ||
125 | file_header->name = xstrndup(tar.name, sizeof(tar.name)); | ||
126 | if (tar.prefix[0]) { | ||
127 | char *temp = file_header->name; | ||
128 | file_header->name = concat_path_file(tar.prefix, temp); | ||
129 | free(temp); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | /* getOctal trashes subsequent field, therefore we call it | 114 | /* getOctal trashes subsequent field, therefore we call it |
134 | * on fields in reverse order */ | 115 | * on fields in reverse order */ |
135 | #define GET_OCTAL(a) getOctal((a), sizeof(a)) | 116 | #define GET_OCTAL(a) getOctal((a), sizeof(a)) |
@@ -148,6 +129,24 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
148 | file_header->mode = 07777 & GET_OCTAL(tar.mode); | 129 | file_header->mode = 07777 & GET_OCTAL(tar.mode); |
149 | #undef GET_OCTAL | 130 | #undef GET_OCTAL |
150 | 131 | ||
132 | #ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS | ||
133 | if (longname) { | ||
134 | file_header->name = longname; | ||
135 | longname = NULL; | ||
136 | } | ||
137 | else if (linkname) { | ||
138 | file_header->name = linkname; | ||
139 | linkname = NULL; | ||
140 | } else | ||
141 | #endif | ||
142 | { /* we trash mode[0] here, it's ok */ | ||
143 | tar.name[sizeof(tar.name)] = '\0'; | ||
144 | if (tar.prefix[0]) | ||
145 | file_header->name = concat_path_file(tar.prefix, tar.name); | ||
146 | else | ||
147 | file_header->name = xstrdup(tar.name); | ||
148 | } | ||
149 | |||
151 | /* Set bits 12-15 of the files mode */ | 150 | /* Set bits 12-15 of the files mode */ |
152 | switch (tar.typeflag) { | 151 | switch (tar.typeflag) { |
153 | /* busybox identifies hard links as being regular files with 0 size and a link name */ | 152 | /* busybox identifies hard links as being regular files with 0 size and a link name */ |
@@ -209,10 +208,12 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
209 | /* Strip trailing '/' in directories */ | 208 | /* Strip trailing '/' in directories */ |
210 | /* Must be done after mode is set as '/' is used to check if its a directory */ | 209 | /* Must be done after mode is set as '/' is used to check if its a directory */ |
211 | cp = last_char_is(file_header->name, '/'); | 210 | cp = last_char_is(file_header->name, '/'); |
212 | if (cp) *cp = '\0'; | ||
213 | 211 | ||
214 | if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { | 212 | if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { |
215 | archive_handle->action_header(archive_handle->file_header); | 213 | archive_handle->action_header(archive_handle->file_header); |
214 | /* Note that we kill the '/' only after action_header() */ | ||
215 | /* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */ | ||
216 | if (cp) *cp = '\0'; | ||
216 | archive_handle->flags |= ARCHIVE_EXTRACT_QUIET; | 217 | archive_handle->flags |= ARCHIVE_EXTRACT_QUIET; |
217 | archive_handle->action_data(archive_handle); | 218 | archive_handle->action_data(archive_handle); |
218 | llist_add_to(&(archive_handle->passed), file_header->name); | 219 | llist_add_to(&(archive_handle->passed), file_header->name); |
diff --git a/archival/libunarchive/header_verbose_list.c b/archival/libunarchive/header_verbose_list.c index 130b6a268..7b97e524c 100644 --- a/archival/libunarchive/header_verbose_list.c +++ b/archival/libunarchive/header_verbose_list.c | |||
@@ -3,9 +3,6 @@ | |||
3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdio.h> | ||
7 | #include <string.h> | ||
8 | #include <time.h> | ||
9 | #include "libbb.h" | 6 | #include "libbb.h" |
10 | #include "unarchive.h" | 7 | #include "unarchive.h" |
11 | 8 | ||
@@ -13,11 +10,11 @@ void header_verbose_list(const file_header_t *file_header) | |||
13 | { | 10 | { |
14 | struct tm *mtime = localtime(&(file_header->mtime)); | 11 | struct tm *mtime = localtime(&(file_header->mtime)); |
15 | 12 | ||
16 | printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s", | 13 | printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s", |
17 | bb_mode_string(file_header->mode), | 14 | bb_mode_string(file_header->mode), |
18 | file_header->uid, | 15 | file_header->uid, |
19 | file_header->gid, | 16 | file_header->gid, |
20 | (unsigned int) file_header->size, | 17 | file_header->size, |
21 | 1900 + mtime->tm_year, | 18 | 1900 + mtime->tm_year, |
22 | 1 + mtime->tm_mon, | 19 | 1 + mtime->tm_mon, |
23 | mtime->tm_mday, | 20 | mtime->tm_mday, |
diff --git a/archival/tar.c b/archival/tar.c index 911c2d35e..6aaa42273 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -563,9 +563,9 @@ static char get_header_tar_Z(archive_handle_t *archive_handle) | |||
563 | archive_handle->seek = seek_by_read; | 563 | archive_handle->seek = seek_by_read; |
564 | 564 | ||
565 | /* do the decompression, and cleanup */ | 565 | /* do the decompression, and cleanup */ |
566 | if (xread_char(archive_handle->src_fd) != 0x1f || | 566 | if (xread_char(archive_handle->src_fd) != 0x1f |
567 | xread_char(archive_handle->src_fd) != 0x9d) | 567 | || xread_char(archive_handle->src_fd) != 0x9d |
568 | { | 568 | ) { |
569 | bb_error_msg_and_die("invalid magic"); | 569 | bb_error_msg_and_die("invalid magic"); |
570 | } | 570 | } |
571 | 571 | ||