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 /tests/tar_fuzz.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 'tests/tar_fuzz.c')
-rw-r--r-- | tests/tar_fuzz.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/tar_fuzz.c b/tests/tar_fuzz.c index f342e38..e5f5c0b 100644 --- a/tests/tar_fuzz.c +++ b/tests/tar_fuzz.c @@ -14,7 +14,7 @@ int main(int argc, char **argv) { tar_header_decoded_t hdr; - FILE *fp; + istream_t *fp; int ret; if (argc != 2) { @@ -22,11 +22,9 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - fp = fopen(argv[1], "rb"); - if (fp == NULL) { - perror(argv[1]); + fp = istream_open_file(argv[1]); + if (fp == NULL) return EXIT_FAILURE; - } for (;;) { ret = read_header(fp, &hdr); @@ -35,16 +33,16 @@ int main(int argc, char **argv) if (ret < 0) goto fail; - ret = fseek(fp, hdr.sb.st_size, SEEK_CUR); + ret = istream_skip(fp, hdr.sb.st_size); clear_header(&hdr); if (ret < 0) goto fail; } - fclose(fp); + sqfs_destroy(fp); return EXIT_SUCCESS; fail: - fclose(fp); + sqfs_destroy(fp); return EXIT_FAILURE; } |