summaryrefslogtreecommitdiff
path: root/src/archive.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-01-11 09:56:42 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-01-11 11:32:51 +0200
commitf123d77e0b903b7459296291e04b6558ceb4c287 (patch)
tree75cc6e28f5f3d86d63922762072a3392d2bb81cb /src/archive.c
parent1de9ef422c087ee8fc302c9d889dd373dc6dde58 (diff)
downloadapk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.gz
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.bz2
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.xz
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.zip
archive: make apk_tar_parse check and close input stream
simplifies other code quite a bit
Diffstat (limited to 'src/archive.c')
-rw-r--r--src/archive.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/archive.c b/src/archive.c
index eabd3bf..24676b1 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -138,6 +138,8 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
apk_blob_t pax = APK_BLOB_NULL, longname = APK_BLOB_NULL;
char filename[sizeof buf.name + sizeof buf.prefix + 2];
+ if (IS_ERR_OR_NULL(is)) return PTR_ERR(is) ?: -EINVAL;
+
memset(&entry, 0, sizeof(entry));
entry.name = buf.name;
while ((r = apk_istream_read(is, &buf, 512)) == 512) {
@@ -262,6 +264,7 @@ ok:
free(pax.ptr);
free(longname.ptr);
apk_fileinfo_free(&entry);
+ apk_istream_close(is);
return r;
}