1 /* vi: set sw=4 ts=4: */
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 #include "unarchive.h" /* for external decl of check_header_gzip */
10 void check_header_gzip(int src_fd)
18 unsigned char xtra_flags;
19 unsigned char os_flags;
23 xread(src_fd, header.raw, 8);
25 /* Check the compression method */
26 if (header.formated.method != 8) {
27 bb_error_msg_and_die("Unknown compression method %d",
28 header.formated.method);
31 if (header.formated.flags & 0x04) {
32 /* bit 2 set: extra field present */
33 unsigned char extra_short;
35 extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
36 while (extra_short > 0) {
37 /* Ignore extra field */
43 /* Discard original name if any */
44 if (header.formated.flags & 0x08) {
45 /* bit 3 set: original file name present */
46 while(xread_char(src_fd) != 0);
49 /* Discard file comment if any */
50 if (header.formated.flags & 0x10) {
51 /* bit 4 set: file comment present */
52 while(xread_char(src_fd) != 0);
55 /* Read the header checksum */
56 if (header.formated.flags & 0x02) {