diff options
Diffstat (limited to 'lib/tar')
-rw-r--r-- | lib/tar/read_header.c | 30 | ||||
-rw-r--r-- | lib/tar/read_sparse_map_old.c | 13 | ||||
-rw-r--r-- | lib/tar/skip.c | 12 |
3 files changed, 10 insertions, 45 deletions
diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c index 94c4a69..1769e0a 100644 --- a/lib/tar/read_header.c +++ b/lib/tar/read_header.c @@ -31,18 +31,12 @@ static int check_version(const tar_header_t *hdr) static char *record_to_memory(int fd, uint64_t size) { char *buffer = malloc(size + 1); - ssize_t ret; if (buffer == NULL) goto fail_errno; - ret = read_retry(fd, buffer, size); - if (ret == 0) - goto fail_eof; - if (ret < 0) - goto fail_errno; - if ((uint64_t)ret < size) - goto fail_eof; + if (read_data("reading tar record", fd, buffer, size)) + goto fail; if (skip_padding(fd, size)) goto fail; @@ -52,9 +46,6 @@ static char *record_to_memory(int fd, uint64_t size) fail_errno: perror("reading tar record"); goto fail; -fail_eof: - fputs("reading tar record: unexpected end of file\n", stderr); - goto fail; fail: free(buffer); return NULL; @@ -416,18 +407,13 @@ int read_header(int fd, tar_header_decoded_t *out) bool prev_was_zero = false; uint64_t pax_size; tar_header_t hdr; - int ret, version; + int version; memset(out, 0, sizeof(*out)); for (;;) { - ret = read_retry(fd, &hdr, sizeof(hdr)); - if (ret == 0) - goto out_eof; - if (ret < 0) - goto fail_errno; - if (ret < (int)sizeof(hdr)) - goto fail_eof; + if (read_data("reading tar header", fd, &hdr, sizeof(hdr))) + goto fail; if (is_zero_block(&hdr)) { if (prev_was_zero) @@ -499,12 +485,6 @@ int read_header(int fd, tar_header_decoded_t *out) out_eof: clear_header(out); return 1; -fail_errno: - perror("reading tar header"); - goto fail; -fail_eof: - fputs("reading tar header: unexpected end of file\n", stderr); - goto fail; fail_magic: fputs("input is not a ustar tar archive!\n", stderr); goto fail; diff --git a/lib/tar/read_sparse_map_old.c b/lib/tar/read_sparse_map_old.c index c0b2d0d..41d309a 100644 --- a/lib/tar/read_sparse_map_old.c +++ b/lib/tar/read_sparse_map_old.c @@ -6,7 +6,6 @@ sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr) sparse_map_t *list = NULL, *end = NULL, *node; gnu_sparse_t sph; uint64_t off, sz; - ssize_t ret; int i; for (i = 0; i < 4; ++i) { @@ -41,11 +40,10 @@ sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr) return list; do { - ret = read_retry(fd, &sph, sizeof(sph)); - if (ret < 0) - goto fail_errno; - if ((size_t)ret < sizeof(sph)) - goto fail_eof; + if (read_data("reading GNU sparse header", + fd, &sph, sizeof(sph))) { + goto fail; + } for (i = 0; i < 21; ++i) { if (!isdigit(sph.sparse[i].offset[0])) @@ -77,9 +75,6 @@ sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr) } while (sph.isextended != 0); return list; -fail_eof: - fputs("parsing GNU sparse header: unexpected end of file", stderr); - goto fail; fail_errno: perror("parsing GNU sparse header"); goto fail; diff --git a/lib/tar/skip.c b/lib/tar/skip.c index 69208b2..28c02be 100644 --- a/lib/tar/skip.c +++ b/lib/tar/skip.c @@ -7,7 +7,6 @@ static int skip_bytes(int fd, uint64_t size) { unsigned char buffer[1024]; - ssize_t ret; size_t diff; while (size != 0) { @@ -15,17 +14,8 @@ static int skip_bytes(int fd, uint64_t size) if (diff > size) diff = size; - ret = read_retry(fd, buffer, diff); - - if (ret < 0) { - perror("reading tar record data"); - return -1; - } - - if ((size_t)ret < diff) { - fputs("unexpected end of file\n", stderr); + if (read_data("reading tar record padding", fd, buffer, diff)) return -1; - } size -= diff; } |