diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/ar.c | 2 | ||||
-rw-r--r-- | archival/gunzip.c | 4 | ||||
-rw-r--r-- | archival/libunarchive/Makefile.in | 1 | ||||
-rw-r--r-- | archival/libunarchive/archive_xread_all.c | 21 | ||||
-rw-r--r-- | archival/libunarchive/archive_xread_all_eof.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/check_header_gzip.c | 14 | ||||
-rw-r--r-- | archival/libunarchive/data_extract_to_buffer.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/decompress_uncompress.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/decompress_unzip.c | 7 | ||||
-rw-r--r-- | archival/libunarchive/get_header_ar.c | 4 | ||||
-rw-r--r-- | archival/libunarchive/get_header_cpio.c | 5 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar.c | 12 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar_gz.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/unpack_ar_archive.c | 2 | ||||
-rw-r--r-- | archival/rpm.c | 2 | ||||
-rw-r--r-- | archival/rpm2cpio.c | 6 | ||||
-rw-r--r-- | archival/tar.c | 12 | ||||
-rw-r--r-- | archival/uncompress.c | 2 | ||||
-rw-r--r-- | archival/unzip.c | 61 |
19 files changed, 55 insertions, 108 deletions
diff --git a/archival/ar.c b/archival/ar.c index 3bb75879b..fd2ab99a0 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -88,7 +88,7 @@ int ar_main(int argc, char **argv) | |||
88 | llist_add_to(&(archive_handle->accept), argv[optind++]); | 88 | llist_add_to(&(archive_handle->accept), argv[optind++]); |
89 | } | 89 | } |
90 | 90 | ||
91 | archive_xread_all(archive_handle, magic, 7); | 91 | xread(archive_handle->src_fd, magic, 7); |
92 | if (strncmp(magic, "!<arch>", 7) != 0) { | 92 | if (strncmp(magic, "!<arch>", 7) != 0) { |
93 | bb_error_msg_and_die("Invalid ar magic"); | 93 | bb_error_msg_and_die("Invalid ar magic"); |
94 | } | 94 | } |
diff --git a/archival/gunzip.c b/archival/gunzip.c index 069666f58..bd6047e13 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c | |||
@@ -112,10 +112,10 @@ int gunzip_main(int argc, char **argv) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | /* do the decompression, and cleanup */ | 114 | /* do the decompression, and cleanup */ |
115 | if (bb_xread_char(src_fd) == 0x1f) { | 115 | if (xread_char(src_fd) == 0x1f) { |
116 | unsigned char magic2; | 116 | unsigned char magic2; |
117 | 117 | ||
118 | magic2 = bb_xread_char(src_fd); | 118 | magic2 = xread_char(src_fd); |
119 | #ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS | 119 | #ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS |
120 | if (magic2 == 0x9d) { | 120 | if (magic2 == 0x9d) { |
121 | status = uncompress(src_fd, dst_fd); | 121 | status = uncompress(src_fd, dst_fd); |
diff --git a/archival/libunarchive/Makefile.in b/archival/libunarchive/Makefile.in index 928e5bf8b..46c50f81d 100644 --- a/archival/libunarchive/Makefile.in +++ b/archival/libunarchive/Makefile.in | |||
@@ -29,7 +29,6 @@ LIBUNARCHIVE-y:= \ | |||
29 | header_list.o \ | 29 | header_list.o \ |
30 | header_verbose_list.o \ | 30 | header_verbose_list.o \ |
31 | \ | 31 | \ |
32 | archive_xread_all.o \ | ||
33 | archive_xread_all_eof.o \ | 32 | archive_xread_all_eof.o \ |
34 | \ | 33 | \ |
35 | seek_by_char.o \ | 34 | seek_by_char.o \ |
diff --git a/archival/libunarchive/archive_xread_all.c b/archival/libunarchive/archive_xread_all.c deleted file mode 100644 index bed8641a2..000000000 --- a/archival/libunarchive/archive_xread_all.c +++ /dev/null | |||
@@ -1,21 +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 <stdio.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <string.h> | ||
9 | #include "unarchive.h" | ||
10 | #include "libbb.h" | ||
11 | |||
12 | void archive_xread_all(const archive_handle_t *archive_handle, void *buf, const size_t count) | ||
13 | { | ||
14 | ssize_t size; | ||
15 | |||
16 | size = bb_full_read(archive_handle->src_fd, buf, count); | ||
17 | if (size != count) { | ||
18 | bb_error_msg_and_die("Short read"); | ||
19 | } | ||
20 | return; | ||
21 | } | ||
diff --git a/archival/libunarchive/archive_xread_all_eof.c b/archival/libunarchive/archive_xread_all_eof.c index df9c88a56..e03fb0caa 100644 --- a/archival/libunarchive/archive_xread_all_eof.c +++ b/archival/libunarchive/archive_xread_all_eof.c | |||
@@ -13,7 +13,7 @@ ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *b | |||
13 | { | 13 | { |
14 | ssize_t size; | 14 | ssize_t size; |
15 | 15 | ||
16 | size = bb_full_read(archive_handle->src_fd, buf, count); | 16 | size = full_read(archive_handle->src_fd, buf, count); |
17 | if ((size != 0) && (size != count)) { | 17 | if ((size != 0) && (size != count)) { |
18 | bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count); | 18 | bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count); |
19 | } | 19 | } |
diff --git a/archival/libunarchive/check_header_gzip.c b/archival/libunarchive/check_header_gzip.c index 79477c610..77e1e6a46 100644 --- a/archival/libunarchive/check_header_gzip.c +++ b/archival/libunarchive/check_header_gzip.c | |||
@@ -20,7 +20,7 @@ void check_header_gzip(int src_fd) | |||
20 | } formated; | 20 | } formated; |
21 | } header; | 21 | } header; |
22 | 22 | ||
23 | bb_xread_all(src_fd, header.raw, 8); | 23 | xread(src_fd, header.raw, 8); |
24 | 24 | ||
25 | /* Check the compression method */ | 25 | /* Check the compression method */ |
26 | if (header.formated.method != 8) { | 26 | if (header.formated.method != 8) { |
@@ -32,10 +32,10 @@ void check_header_gzip(int src_fd) | |||
32 | /* bit 2 set: extra field present */ | 32 | /* bit 2 set: extra field present */ |
33 | unsigned char extra_short; | 33 | unsigned char extra_short; |
34 | 34 | ||
35 | extra_short = bb_xread_char(src_fd) + (bb_xread_char(src_fd) << 8); | 35 | extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8); |
36 | while (extra_short > 0) { | 36 | while (extra_short > 0) { |
37 | /* Ignore extra field */ | 37 | /* Ignore extra field */ |
38 | bb_xread_char(src_fd); | 38 | xread_char(src_fd); |
39 | extra_short--; | 39 | extra_short--; |
40 | } | 40 | } |
41 | } | 41 | } |
@@ -43,19 +43,19 @@ void check_header_gzip(int src_fd) | |||
43 | /* Discard original name if any */ | 43 | /* Discard original name if any */ |
44 | if (header.formated.flags & 0x08) { | 44 | if (header.formated.flags & 0x08) { |
45 | /* bit 3 set: original file name present */ | 45 | /* bit 3 set: original file name present */ |
46 | while(bb_xread_char(src_fd) != 0); | 46 | while(xread_char(src_fd) != 0); |
47 | } | 47 | } |
48 | 48 | ||
49 | /* Discard file comment if any */ | 49 | /* Discard file comment if any */ |
50 | if (header.formated.flags & 0x10) { | 50 | if (header.formated.flags & 0x10) { |
51 | /* bit 4 set: file comment present */ | 51 | /* bit 4 set: file comment present */ |
52 | while(bb_xread_char(src_fd) != 0); | 52 | while(xread_char(src_fd) != 0); |
53 | } | 53 | } |
54 | 54 | ||
55 | /* Read the header checksum */ | 55 | /* Read the header checksum */ |
56 | if (header.formated.flags & 0x02) { | 56 | if (header.formated.flags & 0x02) { |
57 | bb_xread_char(src_fd); | 57 | xread_char(src_fd); |
58 | bb_xread_char(src_fd); | 58 | xread_char(src_fd); |
59 | } | 59 | } |
60 | 60 | ||
61 | return; | 61 | return; |
diff --git a/archival/libunarchive/data_extract_to_buffer.c b/archival/libunarchive/data_extract_to_buffer.c index fe76971df..95cb8f576 100644 --- a/archival/libunarchive/data_extract_to_buffer.c +++ b/archival/libunarchive/data_extract_to_buffer.c | |||
@@ -14,5 +14,5 @@ void data_extract_to_buffer(archive_handle_t *archive_handle) | |||
14 | 14 | ||
15 | archive_handle->buffer = xzalloc(size + 1); | 15 | archive_handle->buffer = xzalloc(size + 1); |
16 | 16 | ||
17 | archive_xread_all(archive_handle, archive_handle->buffer, size); | 17 | xread(archive_handle->src_fd, archive_handle->buffer, size); |
18 | } | 18 | } |
diff --git a/archival/libunarchive/decompress_uncompress.c b/archival/libunarchive/decompress_uncompress.c index 81764a47f..0c4ab6dda 100644 --- a/archival/libunarchive/decompress_uncompress.c +++ b/archival/libunarchive/decompress_uncompress.c | |||
@@ -116,7 +116,7 @@ int uncompress(int fd_in, int fd_out) | |||
116 | 116 | ||
117 | insize = 0; | 117 | insize = 0; |
118 | 118 | ||
119 | inbuf[0] = bb_xread_char(fd_in); | 119 | inbuf[0] = xread_char(fd_in); |
120 | 120 | ||
121 | maxbits = inbuf[0] & BIT_MASK; | 121 | maxbits = inbuf[0] & BIT_MASK; |
122 | block_mode = inbuf[0] & BLOCK_MODE; | 122 | block_mode = inbuf[0] & BLOCK_MODE; |
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index 46a26933b..8f33e6e6c 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c | |||
@@ -116,9 +116,8 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current | |||
116 | /* Leave the first 4 bytes empty so we can always unwind the bitbuffer | 116 | /* Leave the first 4 bytes empty so we can always unwind the bitbuffer |
117 | * to the front of the bytebuffer, leave 4 bytes free at end of tail | 117 | * to the front of the bytebuffer, leave 4 bytes free at end of tail |
118 | * so we can easily top up buffer in check_trailer_gzip() */ | 118 | * so we can easily top up buffer in check_trailer_gzip() */ |
119 | if (!(bytebuffer_size = bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8))) { | 119 | if (1 > (bytebuffer_size = safe_read(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8))) |
120 | bb_error_msg_and_die("unexpected end of file"); | 120 | bb_error_msg_and_die("unexpected end of file"); |
121 | } | ||
122 | bytebuffer_size += 4; | 121 | bytebuffer_size += 4; |
123 | bytebuffer_offset = 4; | 122 | bytebuffer_offset = 4; |
124 | } | 123 | } |
@@ -862,7 +861,7 @@ int inflate_unzip(int in, int out) | |||
862 | 861 | ||
863 | while(1) { | 862 | while(1) { |
864 | int ret = inflate_get_next_window(); | 863 | int ret = inflate_get_next_window(); |
865 | nwrote = bb_full_write(out, gunzip_window, gunzip_outbuf_count); | 864 | nwrote = full_write(out, gunzip_window, gunzip_outbuf_count); |
866 | if (nwrote == -1) { | 865 | if (nwrote == -1) { |
867 | bb_perror_msg("write"); | 866 | bb_perror_msg("write"); |
868 | return -1; | 867 | return -1; |
@@ -896,7 +895,7 @@ int inflate_gunzip(int in, int out) | |||
896 | /* top up the input buffer with the rest of the trailer */ | 895 | /* top up the input buffer with the rest of the trailer */ |
897 | count = bytebuffer_size - bytebuffer_offset; | 896 | count = bytebuffer_size - bytebuffer_offset; |
898 | if (count < 8) { | 897 | if (count < 8) { |
899 | bb_xread_all(in, &bytebuffer[bytebuffer_size], 8 - count); | 898 | xread(in, &bytebuffer[bytebuffer_size], 8 - count); |
900 | bytebuffer_size += 8 - count; | 899 | bytebuffer_size += 8 - count; |
901 | } | 900 | } |
902 | for (count = 0; count != 4; count++) { | 901 | for (count = 0; count != 4; count++) { |
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c index 44d964287..48d7a5ad8 100644 --- a/archival/libunarchive/get_header_ar.c +++ b/archival/libunarchive/get_header_ar.c | |||
@@ -43,7 +43,7 @@ char get_header_ar(archive_handle_t *archive_handle) | |||
43 | if (ar.raw[0] == '\n') { | 43 | if (ar.raw[0] == '\n') { |
44 | /* fix up the header, we started reading 1 byte too early */ | 44 | /* fix up the header, we started reading 1 byte too early */ |
45 | memmove(ar.raw, &ar.raw[1], 59); | 45 | memmove(ar.raw, &ar.raw[1], 59); |
46 | ar.raw[59] = bb_xread_char(archive_handle->src_fd); | 46 | ar.raw[59] = xread_char(archive_handle->src_fd); |
47 | archive_handle->offset++; | 47 | archive_handle->offset++; |
48 | } | 48 | } |
49 | archive_handle->offset += 60; | 49 | archive_handle->offset += 60; |
@@ -68,7 +68,7 @@ char get_header_ar(archive_handle_t *archive_handle) | |||
68 | * in static variable long_names for use in future entries */ | 68 | * in static variable long_names for use in future entries */ |
69 | ar_long_name_size = typed->size; | 69 | ar_long_name_size = typed->size; |
70 | ar_long_names = xmalloc(ar_long_name_size); | 70 | ar_long_names = xmalloc(ar_long_name_size); |
71 | bb_xread_all(archive_handle->src_fd, ar_long_names, ar_long_name_size); | 71 | xread(archive_handle->src_fd, ar_long_names, ar_long_name_size); |
72 | archive_handle->offset += ar_long_name_size; | 72 | archive_handle->offset += ar_long_name_size; |
73 | /* This ar entries data section only contained filenames for other records | 73 | /* This ar entries data section only contained filenames for other records |
74 | * they are stored in the static ar_long_names for future reference */ | 74 | * they are stored in the static ar_long_names for future reference */ |
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c index 725c4911a..28c743589 100644 --- a/archival/libunarchive/get_header_cpio.c +++ b/archival/libunarchive/get_header_cpio.c | |||
@@ -76,7 +76,8 @@ char get_header_cpio(archive_handle_t *archive_handle) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | file_header->name = (char *) xzalloc(namesize + 1); | 78 | file_header->name = (char *) xzalloc(namesize + 1); |
79 | archive_xread_all(archive_handle, file_header->name, namesize); /* Read in filename */ | 79 | /* Read in filename */ |
80 | xread(archive_handle->src_fd, file_header->name, namesize); | ||
80 | archive_handle->offset += namesize; | 81 | archive_handle->offset += namesize; |
81 | 82 | ||
82 | /* Update offset amount and skip padding before file contents */ | 83 | /* Update offset amount and skip padding before file contents */ |
@@ -103,7 +104,7 @@ char get_header_cpio(archive_handle_t *archive_handle) | |||
103 | 104 | ||
104 | if (S_ISLNK(file_header->mode)) { | 105 | if (S_ISLNK(file_header->mode)) { |
105 | file_header->link_name = (char *) xzalloc(file_header->size + 1); | 106 | file_header->link_name = (char *) xzalloc(file_header->size + 1); |
106 | archive_xread_all(archive_handle, file_header->link_name, file_header->size); | 107 | xread(archive_handle->src_fd, file_header->link_name, file_header->size); |
107 | archive_handle->offset += file_header->size; | 108 | archive_handle->offset += file_header->size; |
108 | file_header->size = 0; /* Stop possible seeks in future */ | 109 | file_header->size = 0; /* Stop possible seeks in future */ |
109 | } else { | 110 | } else { |
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index 1cbde9543..4394d23ee 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c | |||
@@ -56,11 +56,7 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
56 | /* Align header */ | 56 | /* Align header */ |
57 | data_align(archive_handle, 512); | 57 | data_align(archive_handle, 512); |
58 | 58 | ||
59 | if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) { | 59 | xread(archive_handle->src_fd, tar.raw, 512); |
60 | /* Assume end of file */ | ||
61 | bb_error_msg_and_die("Short header"); | ||
62 | //return(EXIT_FAILURE); | ||
63 | } | ||
64 | archive_handle->offset += 512; | 60 | archive_handle->offset += 512; |
65 | 61 | ||
66 | /* If there is no filename its an empty header */ | 62 | /* If there is no filename its an empty header */ |
@@ -69,7 +65,7 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
69 | /* This is the second consecutive empty header! End of archive! | 65 | /* This is the second consecutive empty header! End of archive! |
70 | * Read until the end to empty the pipe from gz or bz2 | 66 | * Read until the end to empty the pipe from gz or bz2 |
71 | */ | 67 | */ |
72 | while (bb_full_read(archive_handle->src_fd, tar.raw, 512) == 512); | 68 | while (full_read(archive_handle->src_fd, tar.raw, 512) == 512); |
73 | return(EXIT_FAILURE); | 69 | return(EXIT_FAILURE); |
74 | } | 70 | } |
75 | end = 1; | 71 | end = 1; |
@@ -166,14 +162,14 @@ char get_header_tar(archive_handle_t *archive_handle) | |||
166 | #ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS | 162 | #ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS |
167 | case 'L': { | 163 | case 'L': { |
168 | longname = xzalloc(file_header->size + 1); | 164 | longname = xzalloc(file_header->size + 1); |
169 | archive_xread_all(archive_handle, longname, file_header->size); | 165 | xread(archive_handle->src_fd, longname, file_header->size); |
170 | archive_handle->offset += file_header->size; | 166 | archive_handle->offset += file_header->size; |
171 | 167 | ||
172 | return(get_header_tar(archive_handle)); | 168 | return(get_header_tar(archive_handle)); |
173 | } | 169 | } |
174 | case 'K': { | 170 | case 'K': { |
175 | linkname = xzalloc(file_header->size + 1); | 171 | linkname = xzalloc(file_header->size + 1); |
176 | archive_xread_all(archive_handle, linkname, file_header->size); | 172 | xread(archive_handle->src_fd, linkname, file_header->size); |
177 | archive_handle->offset += file_header->size; | 173 | archive_handle->offset += file_header->size; |
178 | 174 | ||
179 | file_header->name = linkname; | 175 | file_header->name = linkname; |
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c index 3e1f466a7..ad26f465a 100644 --- a/archival/libunarchive/get_header_tar_gz.c +++ b/archival/libunarchive/get_header_tar_gz.c | |||
@@ -15,7 +15,7 @@ char get_header_tar_gz(archive_handle_t *archive_handle) | |||
15 | /* Cant lseek over pipe's */ | 15 | /* Cant lseek over pipe's */ |
16 | archive_handle->seek = seek_by_char; | 16 | archive_handle->seek = seek_by_char; |
17 | 17 | ||
18 | archive_xread_all(archive_handle, &magic, 2); | 18 | xread(archive_handle->src_fd, &magic, 2); |
19 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { | 19 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
20 | bb_error_msg_and_die("Invalid gzip magic"); | 20 | bb_error_msg_and_die("Invalid gzip magic"); |
21 | } | 21 | } |
diff --git a/archival/libunarchive/unpack_ar_archive.c b/archival/libunarchive/unpack_ar_archive.c index 47cf812ef..eed528391 100644 --- a/archival/libunarchive/unpack_ar_archive.c +++ b/archival/libunarchive/unpack_ar_archive.c | |||
@@ -12,7 +12,7 @@ void unpack_ar_archive(archive_handle_t *ar_archive) | |||
12 | { | 12 | { |
13 | char magic[7]; | 13 | char magic[7]; |
14 | 14 | ||
15 | archive_xread_all(ar_archive, magic, 7); | 15 | xread(ar_archive->src_fd, magic, 7); |
16 | if (strncmp(magic, "!<arch>", 7) != 0) { | 16 | if (strncmp(magic, "!<arch>", 7) != 0) { |
17 | bb_error_msg_and_die("Invalid ar magic"); | 17 | bb_error_msg_and_die("Invalid ar magic"); |
18 | } | 18 | } |
diff --git a/archival/rpm.c b/archival/rpm.c index 075578971..3b70439a7 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -193,7 +193,7 @@ void extract_cpio_gz(int fd) { | |||
193 | archive_handle->src_fd = fd; | 193 | archive_handle->src_fd = fd; |
194 | archive_handle->offset = 0; | 194 | archive_handle->offset = 0; |
195 | 195 | ||
196 | bb_xread_all(archive_handle->src_fd, &magic, 2); | 196 | xread(archive_handle->src_fd, &magic, 2); |
197 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { | 197 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
198 | bb_error_msg_and_die("Invalid gzip magic"); | 198 | bb_error_msg_and_die("Invalid gzip magic"); |
199 | } | 199 | } |
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c index 51807c7e2..6aae150e2 100644 --- a/archival/rpm2cpio.c +++ b/archival/rpm2cpio.c | |||
@@ -40,7 +40,7 @@ static void skip_header(int rpm_fd) | |||
40 | { | 40 | { |
41 | struct rpm_header header; | 41 | struct rpm_header header; |
42 | 42 | ||
43 | bb_xread_all(rpm_fd, &header, sizeof(struct rpm_header)); | 43 | xread(rpm_fd, &header, sizeof(struct rpm_header)); |
44 | if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) { | 44 | if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) { |
45 | bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */ | 45 | bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */ |
46 | } | 46 | } |
@@ -66,7 +66,7 @@ int rpm2cpio_main(int argc, char **argv) | |||
66 | rpm_fd = bb_xopen(argv[1], O_RDONLY); | 66 | rpm_fd = bb_xopen(argv[1], O_RDONLY); |
67 | } | 67 | } |
68 | 68 | ||
69 | bb_xread_all(rpm_fd, &lead, sizeof(struct rpm_lead)); | 69 | xread(rpm_fd, &lead, sizeof(struct rpm_lead)); |
70 | if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) { | 70 | if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) { |
71 | bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ | 71 | bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ |
72 | } | 72 | } |
@@ -78,7 +78,7 @@ int rpm2cpio_main(int argc, char **argv) | |||
78 | /* Skip the main header */ | 78 | /* Skip the main header */ |
79 | skip_header(rpm_fd); | 79 | skip_header(rpm_fd); |
80 | 80 | ||
81 | bb_xread_all(rpm_fd, &magic, 2); | 81 | xread(rpm_fd, &magic, 2); |
82 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { | 82 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
83 | bb_error_msg_and_die("Invalid gzip magic"); | 83 | bb_error_msg_and_die("Invalid gzip magic"); |
84 | } | 84 | } |
diff --git a/archival/tar.c b/archival/tar.c index 5b7c1425a..426176bd2 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -269,9 +269,9 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo, | |||
269 | putOctal(header.chksum, 7, chksum); | 269 | putOctal(header.chksum, 7, chksum); |
270 | 270 | ||
271 | /* Now write the header out to disk */ | 271 | /* Now write the header out to disk */ |
272 | if ((size = | 272 | if ((size = full_write(tbInfo->tarFd, (char *) &header, |
273 | bb_full_write(tbInfo->tarFd, (char *) &header, | 273 | sizeof(struct TarHeader))) < 0) |
274 | sizeof(struct TarHeader))) < 0) { | 274 | { |
275 | bb_error_msg(bb_msg_io_error, real_name); | 275 | bb_error_msg(bb_msg_io_error, real_name); |
276 | return (FALSE); | 276 | return (FALSE); |
277 | } | 277 | } |
@@ -475,7 +475,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag, | |||
475 | while (1) { | 475 | while (1) { |
476 | char buf; | 476 | char buf; |
477 | 477 | ||
478 | int n = bb_full_read(gzipStatusPipe[0], &buf, 1); | 478 | int n = full_read(gzipStatusPipe[0], &buf, 1); |
479 | 479 | ||
480 | if (n == 0 && vfork_exec_errno != 0) { | 480 | if (n == 0 && vfork_exec_errno != 0) { |
481 | errno = vfork_exec_errno; | 481 | errno = vfork_exec_errno; |
@@ -562,8 +562,8 @@ static char get_header_tar_Z(archive_handle_t *archive_handle) | |||
562 | archive_handle->seek = seek_by_char; | 562 | archive_handle->seek = seek_by_char; |
563 | 563 | ||
564 | /* do the decompression, and cleanup */ | 564 | /* do the decompression, and cleanup */ |
565 | if (bb_xread_char(archive_handle->src_fd) != 0x1f || | 565 | if (xread_char(archive_handle->src_fd) != 0x1f || |
566 | bb_xread_char(archive_handle->src_fd) != 0x9d) | 566 | xread_char(archive_handle->src_fd) != 0x9d) |
567 | { | 567 | { |
568 | bb_error_msg_and_die("Invalid magic"); | 568 | bb_error_msg_and_die("Invalid magic"); |
569 | } | 569 | } |
diff --git a/archival/uncompress.c b/archival/uncompress.c index b282fe811..801293fd9 100644 --- a/archival/uncompress.c +++ b/archival/uncompress.c | |||
@@ -70,7 +70,7 @@ int uncompress_main(int argc, char **argv) | |||
70 | } | 70 | } |
71 | 71 | ||
72 | /* do the decompression, and cleanup */ | 72 | /* do the decompression, and cleanup */ |
73 | if ((bb_xread_char(src_fd) != 0x1f) || (bb_xread_char(src_fd) != 0x9d)) { | 73 | if ((xread_char(src_fd) != 0x1f) || (xread_char(src_fd) != 0x9d)) { |
74 | bb_error_msg_and_die("Invalid magic"); | 74 | bb_error_msg_and_die("Invalid magic"); |
75 | } | 75 | } |
76 | 76 | ||
diff --git a/archival/unzip.c b/archival/unzip.c index 8ba39e9af..632cc8551 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -32,28 +32,10 @@ | |||
32 | #include "unarchive.h" | 32 | #include "unarchive.h" |
33 | #include "busybox.h" | 33 | #include "busybox.h" |
34 | 34 | ||
35 | #if BB_BIG_ENDIAN | 35 | #define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50) |
36 | static inline unsigned short | 36 | #define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50) |
37 | __swap16(unsigned short x) { | 37 | #define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50) |
38 | return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8); | 38 | #define ZIP_DD_MAGIC SWAP_LE32(0x08074b50) |
39 | } | ||
40 | |||
41 | static inline uint32_t | ||
42 | __swap32(uint32_t x) { | ||
43 | return (((x & 0xFF) << 24) | | ||
44 | ((x & 0xFF00) << 8) | | ||
45 | ((x & 0xFF0000) >> 8) | | ||
46 | ((x & 0xFF000000) >> 24)); | ||
47 | } | ||
48 | #else /* it's little-endian */ | ||
49 | # define __swap16(x) (x) | ||
50 | # define __swap32(x) (x) | ||
51 | #endif /* BB_BIG_ENDIAN */ | ||
52 | |||
53 | #define ZIP_FILEHEADER_MAGIC __swap32(0x04034b50) | ||
54 | #define ZIP_CDS_MAGIC __swap32(0x02014b50) | ||
55 | #define ZIP_CDS_END_MAGIC __swap32(0x06054b50) | ||
56 | #define ZIP_DD_MAGIC __swap32(0x08074b50) | ||
57 | 39 | ||
58 | extern unsigned int gunzip_crc; | 40 | extern unsigned int gunzip_crc; |
59 | extern unsigned int gunzip_bytes_out; | 41 | extern unsigned int gunzip_bytes_out; |
@@ -83,13 +65,6 @@ static void unzip_skip(int fd, off_t skip) | |||
83 | } | 65 | } |
84 | } | 66 | } |
85 | 67 | ||
86 | static void unzip_read(int fd, void *buf, size_t count) | ||
87 | { | ||
88 | if (bb_xread(fd, buf, count) != count) { | ||
89 | bb_error_msg_and_die(bb_msg_read_error); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | static void unzip_create_leading_dirs(char *fn) | 68 | static void unzip_create_leading_dirs(char *fn) |
94 | { | 69 | { |
95 | /* Create all leading directories */ | 70 | /* Create all leading directories */ |
@@ -248,7 +223,7 @@ int unzip_main(int argc, char **argv) | |||
248 | unsigned int magic; | 223 | unsigned int magic; |
249 | 224 | ||
250 | /* Check magic number */ | 225 | /* Check magic number */ |
251 | unzip_read(src_fd, &magic, 4); | 226 | xread(src_fd, &magic, 4); |
252 | if (magic == ZIP_CDS_MAGIC) { | 227 | if (magic == ZIP_CDS_MAGIC) { |
253 | break; | 228 | break; |
254 | } else if (magic != ZIP_FILEHEADER_MAGIC) { | 229 | } else if (magic != ZIP_FILEHEADER_MAGIC) { |
@@ -256,19 +231,17 @@ int unzip_main(int argc, char **argv) | |||
256 | } | 231 | } |
257 | 232 | ||
258 | /* Read the file header */ | 233 | /* Read the file header */ |
259 | unzip_read(src_fd, zip_header.raw, 26); | 234 | xread(src_fd, zip_header.raw, 26); |
260 | #if BB_BIG_ENDIAN | 235 | zip_header.formated.version = SWAP_LE32(zip_header.formated.version); |
261 | zip_header.formated.version = __swap16(zip_header.formated.version); | 236 | zip_header.formated.flags = SWAP_LE32(zip_header.formated.flags); |
262 | zip_header.formated.flags = __swap16(zip_header.formated.flags); | 237 | zip_header.formated.method = SWAP_LE32(zip_header.formated.method); |
263 | zip_header.formated.method = __swap16(zip_header.formated.method); | 238 | zip_header.formated.modtime = SWAP_LE32(zip_header.formated.modtime); |
264 | zip_header.formated.modtime = __swap16(zip_header.formated.modtime); | 239 | zip_header.formated.moddate = SWAP_LE32(zip_header.formated.moddate); |
265 | zip_header.formated.moddate = __swap16(zip_header.formated.moddate); | 240 | zip_header.formated.crc32 = SWAP_LE32(zip_header.formated.crc32); |
266 | zip_header.formated.crc32 = __swap32(zip_header.formated.crc32); | 241 | zip_header.formated.cmpsize = SWAP_LE32(zip_header.formated.cmpsize); |
267 | zip_header.formated.cmpsize = __swap32(zip_header.formated.cmpsize); | 242 | zip_header.formated.ucmpsize = SWAP_LE32(zip_header.formated.ucmpsize); |
268 | zip_header.formated.ucmpsize = __swap32(zip_header.formated.ucmpsize); | 243 | zip_header.formated.filename_len = SWAP_LE32(zip_header.formated.filename_len); |
269 | zip_header.formated.filename_len = __swap16(zip_header.formated.filename_len); | 244 | zip_header.formated.extra_len = SWAP_LE32(zip_header.formated.extra_len); |
270 | zip_header.formated.extra_len = __swap16(zip_header.formated.extra_len); | ||
271 | #endif /* BB_BIG_ENDIAN */ | ||
272 | if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) { | 245 | if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) { |
273 | bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method); | 246 | bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method); |
274 | } | 247 | } |
@@ -276,7 +249,7 @@ int unzip_main(int argc, char **argv) | |||
276 | /* Read filename */ | 249 | /* Read filename */ |
277 | free(dst_fn); | 250 | free(dst_fn); |
278 | dst_fn = xzalloc(zip_header.formated.filename_len + 1); | 251 | dst_fn = xzalloc(zip_header.formated.filename_len + 1); |
279 | unzip_read(src_fd, dst_fn, zip_header.formated.filename_len); | 252 | xread(src_fd, dst_fn, zip_header.formated.filename_len); |
280 | 253 | ||
281 | /* Skip extra header bytes */ | 254 | /* Skip extra header bytes */ |
282 | unzip_skip(src_fd, zip_header.formated.extra_len); | 255 | unzip_skip(src_fd, zip_header.formated.extra_len); |