diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/libunarchive/Makefile.in | 1 | ||||
-rw-r--r-- | archival/libunarchive/decompress_bunzip2.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/filter_accept_list_reassign.c | 59 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar.c | 4 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar_bz2.c | 39 | ||||
-rw-r--r-- | archival/tar.c | 3 |
6 files changed, 103 insertions, 5 deletions
diff --git a/archival/libunarchive/Makefile.in b/archival/libunarchive/Makefile.in index 469004d5f..5675d092f 100644 --- a/archival/libunarchive/Makefile.in +++ b/archival/libunarchive/Makefile.in | |||
@@ -36,6 +36,7 @@ LIBUNARCHIVE-y:= \ | |||
36 | \ | 36 | \ |
37 | get_header_ar.o \ | 37 | get_header_ar.o \ |
38 | get_header_tar.o \ | 38 | get_header_tar.o \ |
39 | get_header_tar_bz2.o \ | ||
39 | get_header_tar_gz.o \ | 40 | get_header_tar_gz.o \ |
40 | \ | 41 | \ |
41 | header_skip.o \ | 42 | header_skip.o \ |
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c index 00ae5a494..4b611b833 100644 --- a/archival/libunarchive/decompress_bunzip2.c +++ b/archival/libunarchive/decompress_bunzip2.c | |||
@@ -1274,7 +1274,7 @@ save_state_and_return: | |||
1274 | return retVal; | 1274 | return retVal; |
1275 | } | 1275 | } |
1276 | 1276 | ||
1277 | static void BZ2_bzReadClose(void) | 1277 | extern void BZ2_bzReadClose(void) |
1278 | { | 1278 | { |
1279 | if (bzf->initialisedOk) { | 1279 | if (bzf->initialisedOk) { |
1280 | bz_stream *strm = &(bzf->strm); | 1280 | bz_stream *strm = &(bzf->strm); |
diff --git a/archival/libunarchive/filter_accept_list_reassign.c b/archival/libunarchive/filter_accept_list_reassign.c new file mode 100644 index 000000000..fa294c70a --- /dev/null +++ b/archival/libunarchive/filter_accept_list_reassign.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 by Glenn McGrath | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | |||
19 | #include <stdlib.h> | ||
20 | #include <string.h> | ||
21 | #include <unistd.h> | ||
22 | |||
23 | #include "libbb.h" | ||
24 | #include "unarchive.h" | ||
25 | |||
26 | /* | ||
27 | * Reassign the subarchive metadata parser based on the filename extension | ||
28 | * e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz | ||
29 | * or if its a .tar.bz2 make archive_handle->sub_archive handle that | ||
30 | */ | ||
31 | extern char filter_accept_list_reassign(archive_handle_t *archive_handle) | ||
32 | { | ||
33 | /* Check the file entry is in the accept list */ | ||
34 | if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) { | ||
35 | const char *name_ptr; | ||
36 | |||
37 | /* Extract the last 2 extensions */ | ||
38 | name_ptr = strrchr(archive_handle->file_header->name, '.'); | ||
39 | |||
40 | /* Modify the subarchive handler based on the extension */ | ||
41 | #ifdef CONFIG_FEATURE_DEB_TAR_GZ | ||
42 | if (strcmp(name_ptr, ".gz") == 0) { | ||
43 | archive_handle->sub_archive->read = read; | ||
44 | archive_handle->action_data_subarchive = get_header_tar_gz; | ||
45 | return(EXIT_SUCCESS); | ||
46 | } | ||
47 | #endif | ||
48 | #ifdef CONFIG_FEATURE_DEB_TAR_BZ2 | ||
49 | if (strcmp(name_ptr, ".bz2") == 0) { | ||
50 | archive_handle->sub_archive->read = read_bz2; | ||
51 | // BZ2_bzReadOpen(archive_handle->sub_archive->src_fd, NULL, 0); | ||
52 | BZ2_bzReadOpen(archive_handle->src_fd, NULL, 0); | ||
53 | archive_handle->action_data_subarchive = get_header_tar; | ||
54 | return(EXIT_SUCCESS); | ||
55 | } | ||
56 | #endif | ||
57 | } | ||
58 | return(EXIT_FAILURE); | ||
59 | } | ||
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index 20451d996..d3ff1608a 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c | |||
@@ -52,8 +52,8 @@ extern char get_header_tar(archive_handle_t *archive_handle) | |||
52 | /* Align header */ | 52 | /* Align header */ |
53 | data_align(archive_handle, 512); | 53 | data_align(archive_handle, 512); |
54 | 54 | ||
55 | if (archive_xread_all_eof(archive_handle, tar.raw, 512) == 0) { | 55 | if (archive_xread(archive_handle, tar.raw, 512) != 512) { |
56 | /* End of file */ | 56 | /* Assume end of file */ |
57 | return(EXIT_FAILURE); | 57 | return(EXIT_FAILURE); |
58 | } | 58 | } |
59 | archive_handle->offset += 512; | 59 | archive_handle->offset += 512; |
diff --git a/archival/libunarchive/get_header_tar_bz2.c b/archival/libunarchive/get_header_tar_bz2.c new file mode 100644 index 000000000..4e47166f0 --- /dev/null +++ b/archival/libunarchive/get_header_tar_bz2.c | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation; either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU Library General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program; if not, write to the Free Software | ||
14 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
15 | */ | ||
16 | |||
17 | #include <sys/types.h> | ||
18 | #include <signal.h> | ||
19 | #include <stdio.h> | ||
20 | #include <stdlib.h> | ||
21 | #include <string.h> | ||
22 | #include <unistd.h> | ||
23 | #include "libbb.h" | ||
24 | #include "unarchive.h" | ||
25 | |||
26 | extern char get_header_tar_bz2(archive_handle_t *archive_handle) | ||
27 | { | ||
28 | BZ2_bzReadOpen(archive_handle->src_fd, NULL, 0); | ||
29 | |||
30 | archive_handle->offset = 0; | ||
31 | while (get_header_tar(archive_handle) == EXIT_SUCCESS); | ||
32 | |||
33 | /* Cleanup */ | ||
34 | BZ2_bzReadClose(); | ||
35 | |||
36 | /* Can only do one tar.bz2 per archive */ | ||
37 | return(EXIT_FAILURE); | ||
38 | } | ||
39 | |||
diff --git a/archival/tar.c b/archival/tar.c index e1e121a09..95ef33b74 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -748,8 +748,7 @@ int tar_main(int argc, char **argv) | |||
748 | #endif /* CONFIG_FEATURE_TAR_GZIP */ | 748 | #endif /* CONFIG_FEATURE_TAR_GZIP */ |
749 | #ifdef CONFIG_FEATURE_TAR_BZIP2 | 749 | #ifdef CONFIG_FEATURE_TAR_BZIP2 |
750 | if (tar_handle->read == read_bz2) { | 750 | if (tar_handle->read == read_bz2) { |
751 | BZ2_bzReadOpen(tar_handle->src_fd, NULL, 0); | 751 | get_header_tar_bz2(tar_handle); |
752 | while (get_header_tar(tar_handle) == EXIT_SUCCESS); | ||
753 | } else | 752 | } else |
754 | #endif /* CONFIG_FEATURE_TAR_BZIP2 */ | 753 | #endif /* CONFIG_FEATURE_TAR_BZIP2 */ |
755 | 754 | ||