From 2e41d0cb777e6af086b45555551780e02ad13f46 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Fri, 27 Sep 2002 06:46:02 +0000 Subject: Fix compress support and prevent a segfault --- archival/gunzip.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'archival/gunzip.c') diff --git a/archival/gunzip.c b/archival/gunzip.c index 4489204fb..6ec5c69ae 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 */ -- cgit v1.2.3