summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-28 17:19:52 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-28 17:20:50 (EDT)
commitcbb8a97a15b7137ce590eb9ce38067e8eb8c99b0 (patch)
tree6c4f63a4877ee84f237ec3397012686995185f9a /src
parent7ff79b17f55f9289ff5c39764f99cd29143db86b (diff)
ustar: Don't read data after finding named header
Diffstat (limited to 'src')
-rw-r--r--src/ustar.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/ustar.c b/src/ustar.c
index c759781..1bc8261 100644
--- a/src/ustar.c
+++ b/src/ustar.c
@@ -85,6 +85,13 @@ _opkg_opk_ustar_next(struct opkg_opk_ustar *ustar)
size_t i;
char *header_uc;
+ /* Seek through data records until next header record. */
+ while (ustar->data_size_remaining > 0) {
+ if (opkg_opk_ustar_read(ustar, NULL, NULL) == OPKG_OPK_ERROR) {
+ return OPKG_OPK_ERROR;
+ }
+ }
+
/* Decompress next (hopefully valid header) record. */
switch (opkg_opk_gzip_read(ustar->gzip, &ustar->header)) {
case OPKG_OPK_OK:
@@ -225,14 +232,6 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar,
strcpy((*member)->uname, ustar->header.uname);
strcpy((*member)->gname, ustar->header.gname);
- /* Seek through data records until next header record. */
- while (ustar->data_size_remaining > 0) {
- if (opkg_opk_ustar_read(ustar, NULL, NULL) == OPKG_OPK_ERROR) {
- free(*member);
- return OPKG_OPK_ERROR;
- }
- }
-
return OPKG_OPK_OK; /* Possibly more members in archive */
}
@@ -326,14 +325,6 @@ opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar,
}
return OPKG_OPK_OK; /* Member found, but more remain */
}
-
- /* Seek through data records until next header record. */
- while (ustar->data_size_remaining > 0) {
- if (opkg_opk_ustar_read(ustar, NULL, NULL) ==
- OPKG_OPK_ERROR) {
- return OPKG_OPK_ERROR;
- }
- }
}
return OPKG_OPK_ERROR; /* Member not found */