aboutsummaryrefslogtreecommitdiff
path: root/archival/libarchive
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2014-02-02 02:06:38 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2014-02-02 02:06:38 +0100
commit640ce3de07807133796bccd0bdfa146bbfc788c7 (patch)
tree0d17e53405b8cbf71aed4d8ba6c9dc27df14814a /archival/libarchive
parentf1999b5a9d2788cdc120b1ee2ab1de18e95b38f2 (diff)
downloadbusybox-w32-640ce3de07807133796bccd0bdfa146bbfc788c7.tar.gz
busybox-w32-640ce3de07807133796bccd0bdfa146bbfc788c7.tar.bz2
busybox-w32-640ce3de07807133796bccd0bdfa146bbfc788c7.zip
zcat: complain if input is not compressed
function old new delta buffer_fill_and_print 178 191 +13 varvalue 735 743 +8 bbunpack 747 755 +8 open_zipped 85 89 +4 xmalloc_open_zipped_read_close 61 63 +2 get_addr_1 240 242 +2 fbsplash_main 1228 1230 +2 pstree_main 322 321 -1 builtin_type 121 119 -2 do_load 954 926 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/3 up/down: 39/-31) Total: 8 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libarchive')
-rw-r--r--archival/libarchive/get_header_tar.c2
-rw-r--r--archival/libarchive/open_transformer.c19
2 files changed, 6 insertions, 15 deletions
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c
index 54d910431..ba43bb073 100644
--- a/archival/libarchive/get_header_tar.c
+++ b/archival/libarchive/get_header_tar.c
@@ -243,7 +243,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
243 * or not first block (false positive, it's not .gz/.bz2!) */ 243 * or not first block (false positive, it's not .gz/.bz2!) */
244 if (lseek(archive_handle->src_fd, -i, SEEK_CUR) != 0) 244 if (lseek(archive_handle->src_fd, -i, SEEK_CUR) != 0)
245 goto err; 245 goto err;
246 if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_detected:*/ 0) != 0) 246 if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 0) != 0)
247 err: 247 err:
248 bb_error_msg_and_die("invalid tar magic"); 248 bb_error_msg_and_die("invalid tar magic");
249 archive_handle->offset = 0; 249 archive_handle->offset = 0;
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c
index 27854af21..198663041 100644
--- a/archival/libarchive/open_transformer.c
+++ b/archival/libarchive/open_transformer.c
@@ -118,7 +118,7 @@ void FAST_FUNC open_transformer(int fd, const char *transform_prog)
118/* Used by e.g. rpm which gives us a fd without filename, 118/* Used by e.g. rpm which gives us a fd without filename,
119 * thus we can't guess the format from filename's extension. 119 * thus we can't guess the format from filename's extension.
120 */ 120 */
121int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected) 121int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_compressed)
122{ 122{
123 union { 123 union {
124 uint8_t b[4]; 124 uint8_t b[4];
@@ -159,7 +159,7 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
159 } 159 }
160 160
161 /* No known magic seen */ 161 /* No known magic seen */
162 if (fail_if_not_detected) 162 if (fail_if_not_compressed)
163 bb_error_msg_and_die("no gzip" 163 bb_error_msg_and_die("no gzip"
164 IF_FEATURE_SEAMLESS_BZ2("/bzip2") 164 IF_FEATURE_SEAMLESS_BZ2("/bzip2")
165 IF_FEATURE_SEAMLESS_XZ("/xz") 165 IF_FEATURE_SEAMLESS_XZ("/xz")
@@ -180,7 +180,7 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
180 return 0; 180 return 0;
181} 181}
182 182
183int FAST_FUNC open_zipped(const char *fname) 183int FAST_FUNC open_zipped(const char *fname, int fail_if_not_compressed)
184{ 184{
185 int fd; 185 int fd;
186 186
@@ -200,16 +200,7 @@ int FAST_FUNC open_zipped(const char *fname)
200 || (ENABLE_FEATURE_SEAMLESS_BZ2) 200 || (ENABLE_FEATURE_SEAMLESS_BZ2)
201 || (ENABLE_FEATURE_SEAMLESS_XZ) 201 || (ENABLE_FEATURE_SEAMLESS_XZ)
202 ) { 202 ) {
203 /* 203 setup_unzip_on_fd(fd, fail_if_not_compressed);
204 * Do we want to fail_if_not_detected?
205 * In most cases, no: think "insmod non_compressed_module".
206 * A case which would like to fail is "zcat uncompressed_file":
207 * otherwise, it happily outputs uncompressed_file as-is,
208 * which is, strictly speaking, not what is expected.
209 * If this ever becomes a problem, we can add
210 * fail_if_not_detected bool argument to open_zipped().
211 */
212 setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 0);
213 } 204 }
214 205
215 return fd; 206 return fd;
@@ -222,7 +213,7 @@ void* FAST_FUNC xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_
222 int fd; 213 int fd;
223 char *image; 214 char *image;
224 215
225 fd = open_zipped(fname); 216 fd = open_zipped(fname, /*fail_if_not_compressed:*/ 0);
226 if (fd < 0) 217 if (fd < 0)
227 return NULL; 218 return NULL;
228 219