diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-11-06 11:54:56 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-11-06 11:56:02 +0100 |
commit | 4d46b361ff1371a6f3f4f89ed8ca81ee23e86de8 (patch) | |
tree | 0705d7c216ea345665cd38345bc21f8931195849 /lib/tar/read_header.c | |
parent | 3afffc2a59cfc3888a84b2b2305b5312393ff4e8 (diff) |
Remove raw file descriptors from tar read path
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/read_header.c')
-rw-r--r-- | lib/tar/read_header.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c index 760d36a..7ec1333 100644 --- a/lib/tar/read_header.c +++ b/lib/tar/read_header.c @@ -35,17 +35,17 @@ static int check_version(const tar_header_t *hdr) return ETV_UNKNOWN; } -static char *record_to_memory(int fd, sqfs_u64 size) +static char *record_to_memory(FILE *fp, sqfs_u64 size) { char *buffer = malloc(size + 1); if (buffer == NULL) goto fail_errno; - if (read_retry("reading tar record", fd, buffer, size)) + if (read_retry("reading tar record", fp, buffer, size)) goto fail; - if (skip_padding(fd, size)) + if (skip_padding(fp, size)) goto fail; buffer[size] = '\0'; @@ -74,7 +74,7 @@ static tar_xattr_t *mkxattr(const char *key, size_t keylen, return xattr; } -static int read_pax_header(int fd, sqfs_u64 entsize, unsigned int *set_by_pax, +static int read_pax_header(FILE *fp, sqfs_u64 entsize, unsigned int *set_by_pax, tar_header_decoded_t *out) { sparse_map_t *sparse_last = NULL, *sparse; @@ -83,7 +83,7 @@ static int read_pax_header(int fd, sqfs_u64 entsize, unsigned int *set_by_pax, tar_xattr_t *xattr; sqfs_u64 i; - buffer = record_to_memory(fd, entsize); + buffer = record_to_memory(fp, entsize); if (buffer == NULL) return -1; @@ -357,7 +357,7 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax, return 0; } -int read_header(int fd, tar_header_decoded_t *out) +int read_header(FILE *fp, tar_header_decoded_t *out) { unsigned int set_by_pax = 0; bool prev_was_zero = false; @@ -368,7 +368,7 @@ int read_header(int fd, tar_header_decoded_t *out) memset(out, 0, sizeof(*out)); for (;;) { - if (read_retry("reading tar header", fd, &hdr, sizeof(hdr))) + if (read_retry("reading tar header", fp, &hdr, sizeof(hdr))) goto fail; if (is_zero_block(&hdr)) { @@ -394,7 +394,7 @@ int read_header(int fd, tar_header_decoded_t *out) if (pax_size < 1 || pax_size > TAR_MAX_SYMLINK_LEN) goto fail_slink_len; free(out->link_target); - out->link_target = record_to_memory(fd, pax_size); + out->link_target = record_to_memory(fp, pax_size); if (out->link_target == NULL) goto fail; set_by_pax |= PAX_SLINK_TARGET; @@ -405,7 +405,7 @@ int read_header(int fd, tar_header_decoded_t *out) if (pax_size < 1 || pax_size > TAR_MAX_PATH_LEN) goto fail_path_len; free(out->name); - out->name = record_to_memory(fd, pax_size); + out->name = record_to_memory(fp, pax_size); if (out->name == NULL) goto fail; set_by_pax |= PAX_NAME; @@ -417,12 +417,12 @@ int read_header(int fd, tar_header_decoded_t *out) if (pax_size < 1 || pax_size > TAR_MAX_PAX_LEN) goto fail_pax_len; set_by_pax = 0; - if (read_pax_header(fd, pax_size, &set_by_pax, out)) + if (read_pax_header(fp, pax_size, &set_by_pax, out)) goto fail; continue; case TAR_TYPE_GNU_SPARSE: free_sparse_list(out->sparse); - out->sparse = read_gnu_old_sparse(fd, &hdr); + out->sparse = read_gnu_old_sparse(fp, &hdr); if (out->sparse == NULL) goto fail; if (read_number(hdr.tail.gnu.realsize, |