summaryrefslogtreecommitdiff
path: root/archival/libarchive/decompress_unzip.c
diff options
context:
space:
mode:
authorDenys Vlasenko2012-03-06 16:23:50 +0100
committerDenys Vlasenko2012-03-06 16:23:50 +0100
commit59655077c5bf176f01d8d277665ebb92263704ed (patch)
tree0d4393ea09ebe90e35866d27041faf6372f6e87e /archival/libarchive/decompress_unzip.c
parent17eedcad9406c43beddab3906c8c693626c351fb (diff)
downloadbusybox-59655077c5bf176f01d8d277665ebb92263704ed.zip
busybox-59655077c5bf176f01d8d277665ebb92263704ed.tar.gz
preparatory cleanups for seamless uncompression improvements
unpack_gz_stream_with_info: fix buggy error check man: fix possible accesses past the end of a string move seamless uncompression helpers from read_printf.c to open_transformer.c function old new delta show_manpage 153 212 +59 unpack_gz_stream_with_info 520 539 +19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libarchive/decompress_unzip.c')
-rw-r--r--archival/libarchive/decompress_unzip.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/archival/libarchive/decompress_unzip.c b/archival/libarchive/decompress_unzip.c
index aa5d22d..50873e3 100644
--- a/archival/libarchive/decompress_unzip.c
+++ b/archival/libarchive/decompress_unzip.c
@@ -1182,33 +1182,37 @@ static int check_header_gzip(STATE_PARAM unpack_info_t *info)
}
IF_DESKTOP(long long) int FAST_FUNC
-unpack_gz_stream_with_info(int in, int out, unpack_info_t *info)
+unpack_gz_stream_with_info(int src_fd, int dst_fd, unpack_info_t *info)
{
uint32_t v32;
- IF_DESKTOP(long long) int n;
+ IF_DESKTOP(long long) int total, n;
DECLARE_STATE;
- n = 0;
+ total = 0;
ALLOC_STATE;
to_read = -1;
// bytebuffer_max = 0x8000;
bytebuffer = xmalloc(bytebuffer_max);
- gunzip_src_fd = in;
+ gunzip_src_fd = src_fd;
again:
if (!check_header_gzip(PASS_STATE info)) {
bb_error_msg("corrupted data");
- n = -1;
+ total = -1;
goto ret;
}
- n += inflate_unzip_internal(PASS_STATE in, out);
- if (n < 0)
+
+ n = inflate_unzip_internal(PASS_STATE src_fd, dst_fd);
+ if (n < 0) {
+ total = -1;
goto ret;
+ }
+ total += n;
if (!top_up(PASS_STATE 8)) {
bb_error_msg("corrupted data");
- n = -1;
+ total = -1;
goto ret;
}
@@ -1216,7 +1220,7 @@ unpack_gz_stream_with_info(int in, int out, unpack_info_t *info)
v32 = buffer_read_le_u32(PASS_STATE_ONLY);
if ((~gunzip_crc) != v32) {
bb_error_msg("crc error");
- n = -1;
+ total = -1;
goto ret;
}
@@ -1224,7 +1228,7 @@ unpack_gz_stream_with_info(int in, int out, unpack_info_t *info)
v32 = buffer_read_le_u32(PASS_STATE_ONLY);
if ((uint32_t)gunzip_bytes_out != v32) {
bb_error_msg("incorrect length");
- n = -1;
+ total = -1;
}
if (!top_up(PASS_STATE 2))
@@ -1242,7 +1246,7 @@ unpack_gz_stream_with_info(int in, int out, unpack_info_t *info)
ret:
free(bytebuffer);
DEALLOC_STATE;
- return n;
+ return total;
}
IF_DESKTOP(long long) int FAST_FUNC