diff options
author | Glenn L McGrath | 2002-09-27 06:46:02 +0000 |
---|---|---|
committer | Glenn L McGrath | 2002-09-27 06:46:02 +0000 |
commit | 2e41d0cb777e6af086b45555551780e02ad13f46 (patch) | |
tree | a53d807aeb25003e5a8ea22461079a10b5238e4d /archival/gunzip.c | |
parent | a47a3eada6ada1168205f6684e5c5a5c23d3558b (diff) | |
download | busybox-2e41d0cb777e6af086b45555551780e02ad13f46.zip busybox-2e41d0cb777e6af086b45555551780e02ad13f46.tar.gz |
Fix compress support and prevent a segfault
Diffstat (limited to 'archival/gunzip.c')
-rw-r--r-- | archival/gunzip.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/archival/gunzip.c b/archival/gunzip.c index 4489204..6ec5c69 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c @@ -163,11 +163,25 @@ extern int gunzip_main(int argc, char **argv) } /* do the decompression, and cleanup */ - check_header_gzip(src_fd); - if (inflate(src_fd, dst_fd) != 0) { - error_msg("Error inflating"); + if (xread_char(src_fd) == 0x1f) { + unsigned char magic2; + + magic2 = xread_char(src_fd); +#ifdef CONFIG_FEATURE_UNCOMPRESS + if (magic2 == 0x9d) { + return(uncompress(src_fd, dst_fd)); + } else +#endif + if (magic2 == 0x8b) { + check_header_gzip(src_fd); + if (inflate(src_fd, dst_fd) != 0) { + error_msg("Error inflating"); + } + check_trailer_gzip(src_fd); + } else { + error_msg_and_die("Invalid magic\n"); + } } - check_trailer_gzip(src_fd); if ((status != EXIT_SUCCESS) && (new_path)) { /* Unzip failed, remove new path instead of old path */ |