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/libunarchive/get_header_tar_gz.c | |
parent | a47a3eada6ada1168205f6684e5c5a5c23d3558b (diff) | |
download | busybox-2e41d0cb777e6af086b45555551780e02ad13f46.zip busybox-2e41d0cb777e6af086b45555551780e02ad13f46.tar.gz |
Fix compress support and prevent a segfault
Diffstat (limited to 'archival/libunarchive/get_header_tar_gz.c')
-rw-r--r-- | archival/libunarchive/get_header_tar_gz.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c index c06beac..24d19fb 100644 --- a/archival/libunarchive/get_header_tar_gz.c +++ b/archival/libunarchive/get_header_tar_gz.c @@ -27,11 +27,17 @@ extern char get_header_tar_gz(archive_handle_t *archive_handle) { int fd_pipe[2]; int pid; + unsigned char magic[2]; + + xread_all(archive_handle->src_fd, &magic, 2); + if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { + error_msg_and_die("Invalid gzip magic"); + } check_header_gzip(archive_handle->src_fd); if (pipe(fd_pipe) != 0) { - error_msg_and_die("Can't create pipe\n"); + error_msg_and_die("Can't create pipe"); } pid = fork(); @@ -54,6 +60,7 @@ extern char get_header_tar_gz(archive_handle_t *archive_handle) archive_handle->src_fd = fd_pipe[0]; + archive_handle->offset = 0; while (get_header_tar(archive_handle) == EXIT_SUCCESS); if (kill(pid, SIGTERM) == -1) { |