1 /* vi: set sw=4 ts=4: */
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
7 #include "unarchive.h" /* for external decl of check_header_gzip_or_die */
9 void check_header_gzip_or_die(int src_fd)
17 unsigned char xtra_flags;
18 unsigned char os_flags;
22 xread(src_fd, header.raw, 8);
24 /* Check the compression method */
25 if (header.formatted.method != 8) {
26 bb_error_msg_and_die("unknown compression method %d",
27 header.formatted.method);
30 if (header.formatted.flags & 0x04) {
31 /* bit 2 set: extra field present */
34 extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
35 while (extra_short > 0) {
36 /* Ignore extra field */
42 /* Discard original name if any */
43 if (header.formatted.flags & 0x08) {
44 /* bit 3 set: original file name present */
45 while (xread_char(src_fd) != 0);
48 /* Discard file comment if any */
49 if (header.formatted.flags & 0x10) {
50 /* bit 4 set: file comment present */
51 while (xread_char(src_fd) != 0);
54 /* Read the header checksum */
55 if (header.formatted.flags & 0x02) {