Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/archival/libunarchive/check_header_gzip.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/archival/libunarchive/check_header_gzip.c
r821 r1770 1 #include <stdlib.h> 2 #include <unistd.h> 1 /* vi: set sw=4 ts=4: */ 2 /* 3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 4 */ 5 3 6 #include "libbb.h" 4 #include "unarchive.h" /* for external decl of check_header_gzip */7 #include "unarchive.h" /* for external decl of check_header_gzip_or_die */ 5 8 6 void check_header_gzip (int src_fd)9 void check_header_gzip_or_die(int src_fd) 7 10 { 8 11 union { … … 14 17 unsigned char xtra_flags; 15 18 unsigned char os_flags; 16 } format ed;19 } formatted; 17 20 } header; 18 21 19 bb_xread_all(src_fd, header.raw, 8);22 xread(src_fd, header.raw, 8); 20 23 21 24 /* Check the compression method */ 22 if (header.format ed.method != 8) {23 bb_error_msg_and_die(" Unknown compression method %d",24 header.format ed.method);25 if (header.formatted.method != 8) { 26 bb_error_msg_and_die("unknown compression method %d", 27 header.formatted.method); 25 28 } 26 29 27 if (header.format ed.flags & 0x04) {30 if (header.formatted.flags & 0x04) { 28 31 /* bit 2 set: extra field present */ 29 unsigned charextra_short;32 unsigned extra_short; 30 33 31 extra_short = bb_xread_char(src_fd) + (bb_xread_char(src_fd) << 8);34 extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8); 32 35 while (extra_short > 0) { 33 36 /* Ignore extra field */ 34 bb_xread_char(src_fd);37 xread_char(src_fd); 35 38 extra_short--; 36 39 } … … 38 41 39 42 /* Discard original name if any */ 40 if (header.format ed.flags & 0x08) {43 if (header.formatted.flags & 0x08) { 41 44 /* bit 3 set: original file name present */ 42 while (bb_xread_char(src_fd) != 0);45 while (xread_char(src_fd) != 0); 43 46 } 44 47 45 48 /* Discard file comment if any */ 46 if (header.format ed.flags & 0x10) {49 if (header.formatted.flags & 0x10) { 47 50 /* bit 4 set: file comment present */ 48 while (bb_xread_char(src_fd) != 0);51 while (xread_char(src_fd) != 0); 49 52 } 50 53 51 54 /* Read the header checksum */ 52 if (header.format ed.flags & 0x02) {53 bb_xread_char(src_fd);54 bb_xread_char(src_fd);55 if (header.formatted.flags & 0x02) { 56 xread_char(src_fd); 57 xread_char(src_fd); 55 58 } 56 57 return;58 59 }
Note:
See TracChangeset
for help on using the changeset viewer.