aboutsummaryrefslogtreecommitdiff
path: root/tests/tar_fuzz.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 /tests/tar_fuzz.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 'tests/tar_fuzz.c')
-rw-r--r--tests/tar_fuzz.c14
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;
}