summaryrefslogtreecommitdiff
path: root/src/io_archive.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-07-17 23:21:16 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-07-22 15:30:08 +0300
commit7e585512f4409eb4e1635ed4d58e9c9774495dfa (patch)
treea47e9a278ab9178e0dde9cc3ff937b0b4c5a96b2 /src/io_archive.c
parent395e92b66e35ccbd2f07a4857d6da588ec9f51f2 (diff)
downloadapk-tools-7e585512f4409eb4e1635ed4d58e9c9774495dfa.tar.gz
apk-tools-7e585512f4409eb4e1635ed4d58e9c9774495dfa.tar.bz2
apk-tools-7e585512f4409eb4e1635ed4d58e9c9774495dfa.tar.xz
apk-tools-7e585512f4409eb4e1635ed4d58e9c9774495dfa.zip
io: make apk_istream_get/read() fail on incomplete read
Diffstat (limited to 'src/io_archive.c')
-rw-r--r--src/io_archive.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/io_archive.c b/src/io_archive.c
index 1164d7c..ccd512a 100644
--- a/src/io_archive.c
+++ b/src/io_archive.c
@@ -141,7 +141,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
memset(&entry, 0, sizeof(entry));
entry.name = buf.name;
- while ((r = apk_istream_read(is, &buf, 512)) == 512) {
+ while ((r = apk_istream_read_max(is, &buf, 512)) == 512) {
if (buf.name[0] == '\0') {
if (end) break;
end++;
@@ -182,7 +182,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
switch (buf.typeflag) {
case 'L': /* GNU long name extension */
if ((r = blob_realloc(&longname, entry.size+1)) != 0 ||
- (r = apk_istream_read(is, longname.ptr, entry.size)) != entry.size)
+ (r = apk_istream_read(is, longname.ptr, entry.size)) < 0)
goto err;
longname.ptr[entry.size] = 0;
entry.name = longname.ptr;
@@ -219,7 +219,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
case 'x': /* file specific pax header */
paxlen = entry.size;
if ((r = blob_realloc(&pax, (paxlen + 511) & -512)) != 0 ||
- (r = apk_istream_read(is, pax.ptr, paxlen)) != paxlen)
+ (r = apk_istream_read(is, pax.ptr, paxlen)) < 0)
goto err;
toskip -= entry.size;
break;
@@ -244,14 +244,14 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
paxlen = 0;
}
- if (toskip && (r = apk_istream_read(is, NULL, toskip)) != toskip)
+ if (toskip && (r = apk_istream_read(is, NULL, toskip)) < 0)
goto err;
}
/* Read remaining end-of-archive records, to ensure we read all of
* the file. The underlying istream is likely doing checksumming. */
if (r == 512) {
- while ((r = apk_istream_read(is, &buf, 512)) == 512) {
+ while ((r = apk_istream_read_max(is, &buf, 512)) == 512) {
if (buf.name[0] != 0) break;
}
}