summaryrefslogtreecommitdiff
path: root/tests/tar_fuzz.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-06 11:54:56 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-06 11:56:02 +0100
commit4d46b361ff1371a6f3f4f89ed8ca81ee23e86de8 (patch)
tree0705d7c216ea345665cd38345bc21f8931195849 /tests/tar_fuzz.c
parent3afffc2a59cfc3888a84b2b2305b5312393ff4e8 (diff)
Remove raw file descriptors from tar read path
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/tar_fuzz.c')
-rw-r--r--tests/tar_fuzz.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/tar_fuzz.c b/tests/tar_fuzz.c
index dad3d5a..1a51da4 100644
--- a/tests/tar_fuzz.c
+++ b/tests/tar_fuzz.c
@@ -17,36 +17,37 @@
int main(int argc, char **argv)
{
tar_header_decoded_t hdr;
- int fd, ret;
+ FILE *fp;
+ int ret;
if (argc != 2) {
fputs("usage: tar_fuzz <tarball>\n", stderr);
return EXIT_FAILURE;
}
- fd = open(argv[1], O_RDONLY);
- if (fd < 0) {
+ fp = fopen(argv[1], "rb");
+ if (fp == NULL) {
perror(argv[1]);
return EXIT_FAILURE;
}
for (;;) {
- ret = read_header(fd, &hdr);
+ ret = read_header(fp, &hdr);
if (ret > 0)
break;
if (ret < 0)
goto fail;
- ret = lseek(fd, hdr.sb.st_size, SEEK_CUR);
+ ret = fseek(fp, hdr.sb.st_size, SEEK_CUR);
clear_header(&hdr);
if (ret < 0)
goto fail;
}
- close(fd);
+ fclose(fp);
return EXIT_SUCCESS;
fail:
- close(fd);
+ fclose(fp);
return EXIT_FAILURE;
}