From cbb8a97a15b7137ce590eb9ce38067e8eb8c99b0 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 28 Apr 2023 17:19:52 -0400 Subject: ustar: Don't read data after finding named header --- (limited to 'src') 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 */ -- cgit v0.9.1