diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-09-13 13:37:42 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-09-16 09:34:35 +0200 |
commit | f757737060d4daebb24a32e90d912661428708a8 (patch) | |
tree | a6e96145d4fc540e435c13a69c924329db2edb6d /lib/tar/read_sparse_map_new.c | |
parent | c1a2cb729bd5bb5fdadf00cb3968bbc541f79750 (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_new.c')
-rw-r--r-- | lib/tar/read_sparse_map_new.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/tar/read_sparse_map_new.c b/lib/tar/read_sparse_map_new.c index f4f0f92..d9f6c6e 100644 --- a/lib/tar/read_sparse_map_new.c +++ b/lib/tar/read_sparse_map_new.c @@ -28,7 +28,7 @@ static int decode(const char *str, size_t len, size_t *out) return (*str == '\n') ? ((int)count + 1) : -1; } -sparse_map_t *read_gnu_new_sparse(FILE *fp, tar_header_decoded_t *out) +sparse_map_t *read_gnu_new_sparse(istream_t *fp, tar_header_decoded_t *out) { sparse_map_t *last = NULL, *list = NULL, *ent = NULL; size_t i, count, value; @@ -38,8 +38,12 @@ sparse_map_t *read_gnu_new_sparse(FILE *fp, tar_header_decoded_t *out) if (out->record_size < 512) goto fail_format; - if (read_retry("reading GNU sparse map", fp, buffer, 512)) - return NULL; + ret = istream_read(fp, buffer, 512); + if (ret < 0) + goto fail; + + if (ret < 512) + goto fail_format; diff = decode(buffer, 512, &count); if (diff <= 0) @@ -61,10 +65,12 @@ sparse_map_t *read_gnu_new_sparse(FILE *fp, tar_header_decoded_t *out) if (out->record_size < 512) goto fail_format; - if (read_retry("reading GNU sparse map", fp, - buffer + 512, 512)) { - return NULL; - } + ret = istream_read(fp, buffer + 512, 512); + if (ret < 0) + goto fail; + + if (ret < 512) + goto fail_format; ret = decode(buffer + diff, 1024 - diff, &value); if (ret <= 0) |