diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-09-27 06:46:02 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-09-27 06:46:02 +0000 |
commit | 2e41d0cb777e6af086b45555551780e02ad13f46 (patch) | |
tree | a53d807aeb25003e5a8ea22461079a10b5238e4d /archival/gunzip.c | |
parent | a47a3eada6ada1168205f6684e5c5a5c23d3558b (diff) | |
download | busybox-w32-2e41d0cb777e6af086b45555551780e02ad13f46.tar.gz busybox-w32-2e41d0cb777e6af086b45555551780e02ad13f46.tar.bz2 busybox-w32-2e41d0cb777e6af086b45555551780e02ad13f46.zip |
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 4489204fb..6ec5c69ae 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c | |||
@@ -163,11 +163,25 @@ extern int gunzip_main(int argc, char **argv) | |||
163 | } | 163 | } |
164 | 164 | ||
165 | /* do the decompression, and cleanup */ | 165 | /* do the decompression, and cleanup */ |
166 | check_header_gzip(src_fd); | 166 | if (xread_char(src_fd) == 0x1f) { |
167 | if (inflate(src_fd, dst_fd) != 0) { | 167 | unsigned char magic2; |
168 | error_msg("Error inflating"); | 168 | |
169 | magic2 = xread_char(src_fd); | ||
170 | #ifdef CONFIG_FEATURE_UNCOMPRESS | ||
171 | if (magic2 == 0x9d) { | ||
172 | return(uncompress(src_fd, dst_fd)); | ||
173 | } else | ||
174 | #endif | ||
175 | if (magic2 == 0x8b) { | ||
176 | check_header_gzip(src_fd); | ||
177 | if (inflate(src_fd, dst_fd) != 0) { | ||
178 | error_msg("Error inflating"); | ||
179 | } | ||
180 | check_trailer_gzip(src_fd); | ||
181 | } else { | ||
182 | error_msg_and_die("Invalid magic\n"); | ||
183 | } | ||
169 | } | 184 | } |
170 | check_trailer_gzip(src_fd); | ||
171 | 185 | ||
172 | if ((status != EXIT_SUCCESS) && (new_path)) { | 186 | if ((status != EXIT_SUCCESS) && (new_path)) { |
173 | /* Unzip failed, remove new path instead of old path */ | 187 | /* Unzip failed, remove new path instead of old path */ |