aboutsummaryrefslogtreecommitdiff
path: root/lib/tar/read_sparse_map_old.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-13 13:37:42 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-16 09:34:35 +0200
commitf757737060d4daebb24a32e90d912661428708a8 (patch)
treea6e96145d4fc540e435c13a69c924329db2edb6d /lib/tar/read_sparse_map_old.c
parentc1a2cb729bd5bb5fdadf00cb3968bbc541f79750 (diff)
Remodel libtar/tar2sqfs to read data from an istream_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/read_sparse_map_old.c')
-rw-r--r--lib/tar/read_sparse_map_old.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/tar/read_sparse_map_old.c b/lib/tar/read_sparse_map_old.c
index 84e1f9e..cd7177d 100644
--- a/lib/tar/read_sparse_map_old.c
+++ b/lib/tar/read_sparse_map_old.c
@@ -8,12 +8,12 @@
#include "internal.h"
-sparse_map_t *read_gnu_old_sparse(FILE *fp, tar_header_t *hdr)
+sparse_map_t *read_gnu_old_sparse(istream_t *fp, tar_header_t *hdr)
{
sparse_map_t *list = NULL, *end = NULL, *node;
gnu_sparse_t sph;
sqfs_u64 off, sz;
- int i;
+ int i, ret;
for (i = 0; i < 4; ++i) {
if (!isdigit(hdr->tail.gnu.sparse[i].offset[0]))
@@ -47,8 +47,14 @@ sparse_map_t *read_gnu_old_sparse(FILE *fp, tar_header_t *hdr)
return list;
do {
- if (read_retry("reading GNU sparse header",
- fp, &sph, sizeof(sph))) {
+ ret = istream_read(fp, &sph, sizeof(sph));
+ if (ret < 0)
+ goto fail;
+
+ if ((size_t)ret < sizeof(sph)) {
+ fputs("reading GNU sparse header: "
+ "unexpected end-of-file\n",
+ stderr);
goto fail;
}