summaryrefslogtreecommitdiff
path: root/archival/rpm2cpio.c
diff options
context:
space:
mode:
authorGlenn L McGrath2002-09-27 06:46:02 +0000
committerGlenn L McGrath2002-09-27 06:46:02 +0000
commit2e41d0cb777e6af086b45555551780e02ad13f46 (patch)
treea53d807aeb25003e5a8ea22461079a10b5238e4d /archival/rpm2cpio.c
parenta47a3eada6ada1168205f6684e5c5a5c23d3558b (diff)
downloadbusybox-2e41d0cb777e6af086b45555551780e02ad13f46.zip
busybox-2e41d0cb777e6af086b45555551780e02ad13f46.tar.gz
Fix compress support and prevent a segfault
Diffstat (limited to 'archival/rpm2cpio.c')
-rw-r--r--archival/rpm2cpio.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c
index e1e9398..9372dc5 100644
--- a/archival/rpm2cpio.c
+++ b/archival/rpm2cpio.c
@@ -70,6 +70,7 @@ extern int rpm2cpio_main(int argc, char **argv)
{
struct rpm_lead lead;
int rpm_fd;
+ unsigned char magic[2];
if (argc == 1) {
rpm_fd = fileno(stdin);
@@ -88,6 +89,11 @@ extern int rpm2cpio_main(int argc, char **argv)
/* Skip the main header */
skip_header(rpm_fd);
+
+ xread_all(rpm_fd, &magic, 2);
+ if ((magic[0] != 0x1f) || (magic[1] != 0x8b))
+ error_msg_and_die("Invalid gzip magic");
+ }
check_header_gzip(rpm_fd);
if (inflate(rpm_fd, fileno(stdout)) != 0) {