aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/archive.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/archive.c b/src/archive.c
index 1f36604..a1a4052 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -237,9 +237,10 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
switch (buf.typeflag) {
case 'L': /* GNU long name extension */
- if (blob_realloc(&longname, entry.size+1)) goto err_nomem;
+ if ((r = blob_realloc(&longname, entry.size+1)) != 0 ||
+ (r = is->read(is, longname.ptr, entry.size)) != entry.size)
+ goto err;
entry.name = longname.ptr;
- is->read(is, entry.name, entry.size);
entry.name[entry.size] = 0;
offset += entry.size;
entry.size = 0;
@@ -286,8 +287,9 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
case 'x': /* file specific pax header */
paxlen = entry.size;
entry.size = 0;
- if (blob_realloc(&pax, (paxlen + 511) & -512)) goto err_nomem;
- is->read(is, pax.ptr, paxlen);
+ if ((r = blob_realloc(&pax, (paxlen + 511) & -512)) != 0 ||
+ (r = is->read(is, pax.ptr, paxlen)) != paxlen)
+ goto err;
offset += paxlen;
break;
default:
@@ -313,8 +315,10 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
if ((offset + toskip) & 511)
toskip += 512 - ((offset + toskip) & 511);
offset += toskip;
- if (toskip != 0)
- is->read(is, NULL, toskip);
+ if (toskip != 0) {
+ if ((r = is->read(is, NULL, toskip)) != toskip)
+ goto err;
+ }
}
/* Read remaining end-of-archive records, to ensure we read all of
@@ -324,20 +328,16 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
if (buf.name[0] != 0) break;
}
}
-
- /* Check that there was no partial (or non-zero) record */
- if (r > 0) r = -EBADMSG;
-
+ if (r == 0) goto ok;
err:
+ /* Check that there was no partial (or non-zero) record */
+ if (r >= 0) r = -EBADMSG;
+ok:
EVP_MD_CTX_cleanup(&teis.mdctx);
free(pax.ptr);
free(longname.ptr);
apk_fileinfo_free(&entry);
return r;
-
-err_nomem:
- r = -ENOMEM;
- goto err;
}
int apk_tar_write_entry(struct apk_ostream *os, const struct apk_file_info *ae,