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_retry.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_retry.c')
-rw-r--r-- | lib/tar/read_retry.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/tar/read_retry.c b/lib/tar/read_retry.c index 5d06595..f81c52a 100644 --- a/lib/tar/read_retry.c +++ b/lib/tar/read_retry.c @@ -12,23 +12,23 @@ #include "tar.h" -int read_retry(const char *errstr, int fd, void *buffer, size_t size) +int read_retry(const char *errstr, FILE *fp, void *buffer, size_t size) { - ssize_t ret; + size_t ret; while (size > 0) { - ret = read(fd, buffer, size); - if (ret < 0) { - if (errno == EINTR) - continue; - perror(errstr); + if (ferror(fp)) { + fprintf(stderr, "%s: error reading from file\n", + errstr); return -1; } - if (ret == 0) { + + if (feof(fp)) { fprintf(stderr, "%s: short read\n", errstr); return -1; } + ret = fread(buffer, 1, size, fp); size -= ret; buffer = (char *)buffer + ret; } |