diff options
-rw-r--r-- | archival/libunarchive/check_header_gzip.c | 59 | ||||
-rw-r--r-- | coreutils/sum.c | 6 |
2 files changed, 3 insertions, 62 deletions
diff --git a/archival/libunarchive/check_header_gzip.c b/archival/libunarchive/check_header_gzip.c deleted file mode 100644 index 66aa57460..000000000 --- a/archival/libunarchive/check_header_gzip.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
4 | */ | ||
5 | |||
6 | #include "libbb.h" | ||
7 | #include "unarchive.h" /* for external decl of check_header_gzip_or_die */ | ||
8 | |||
9 | void check_header_gzip_or_die(int src_fd) | ||
10 | { | ||
11 | union { | ||
12 | unsigned char raw[8]; | ||
13 | struct { | ||
14 | unsigned char method; | ||
15 | unsigned char flags; | ||
16 | unsigned int mtime; | ||
17 | unsigned char xtra_flags; | ||
18 | unsigned char os_flags; | ||
19 | } formatted; | ||
20 | } header; | ||
21 | |||
22 | xread(src_fd, header.raw, 8); | ||
23 | |||
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); | ||
28 | } | ||
29 | |||
30 | if (header.formatted.flags & 0x04) { | ||
31 | /* bit 2 set: extra field present */ | ||
32 | unsigned extra_short; | ||
33 | |||
34 | extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8); | ||
35 | while (extra_short > 0) { | ||
36 | /* Ignore extra field */ | ||
37 | xread_char(src_fd); | ||
38 | extra_short--; | ||
39 | } | ||
40 | } | ||
41 | |||
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); | ||
46 | } | ||
47 | |||
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); | ||
52 | } | ||
53 | |||
54 | /* Read the header checksum */ | ||
55 | if (header.formatted.flags & 0x02) { | ||
56 | xread_char(src_fd); | ||
57 | xread_char(src_fd); | ||
58 | } | ||
59 | } | ||
diff --git a/coreutils/sum.c b/coreutils/sum.c index 4a3760bb4..a75dd321d 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c | |||
@@ -24,7 +24,7 @@ enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; | |||
24 | static unsigned sum_file(const char *file, const unsigned type) | 24 | static unsigned sum_file(const char *file, const unsigned type) |
25 | { | 25 | { |
26 | #define buf bb_common_bufsiz1 | 26 | #define buf bb_common_bufsiz1 |
27 | uintmax_t total_bytes = 0; | 27 | unsigned long long total_bytes = 0; |
28 | int fd = 0, r; | 28 | int fd = 0, r; |
29 | 29 | ||
30 | /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ | 30 | /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ |
@@ -67,9 +67,9 @@ static unsigned sum_file(const char *file, const unsigned type) | |||
67 | if (type >= SUM_SYSV) { | 67 | if (type >= SUM_SYSV) { |
68 | r = (s & 0xffff) + ((s & 0xffffffff) >> 16); | 68 | r = (s & 0xffff) + ((s & 0xffffffff) >> 16); |
69 | s = (r & 0xffff) + (r >> 16); | 69 | s = (r & 0xffff) + (r >> 16); |
70 | printf("%d %ju %s\n", s, (total_bytes+511)/512, file); | 70 | printf("%d %llu %s\n", s, (total_bytes + 511) / 512, file); |
71 | } else | 71 | } else |
72 | printf("%05d %5ju %s\n", s, (total_bytes+1023)/1024, file); | 72 | printf("%05d %5llu %s\n", s, (total_bytes + 1023) / 1024, file); |
73 | return 1; | 73 | return 1; |
74 | #undef buf | 74 | #undef buf |
75 | } | 75 | } |