diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-13 08:23:57 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-13 08:23:57 (EDT) |
commit | fd9c8d89e43b57149471d7af4378c3424242fe18 (patch) | |
tree | 9aeb2c32a9a93aae982e746cf01a615901c356dc | |
parent | 9a8179ef438ed57ad9e1fb34844eb4f9dae6b138 (diff) |
ustar: Improve end detection
-rw-r--r-- | src/ustar.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ustar.c b/src/ustar.c index c616ac8..7f9666a 100644 --- a/src/ustar.c +++ b/src/ustar.c @@ -58,11 +58,16 @@ _opkg_opk_ustar_next(struct opkg_opk_gzip_state *gzip_state, const char *member, switch ((ret = opkg_opk_gzip_next_record(gzip_state, header))) { case OPKG_OPK_OK: - case OPKG_OPK_END: break; + case OPKG_OPK_END: case OPKG_OPK_ERROR: return OPKG_OPK_ERROR; } + memset(record, 0, 512); + if (strncmp(header, record, 512) == 0) { + /* TODO: End gzip stream */ + return OPKG_OPK_END; + } if (strncmp(header->magic, "ustar", strlen("ustar")) != 0) { return OPKG_OPK_ERROR; } @@ -74,8 +79,8 @@ _opkg_opk_ustar_next(struct opkg_opk_gzip_state *gzip_state, const char *member, for (i = 0; i < (size + 511) / 512; ++i) { switch ((ret = opkg_opk_gzip_next_record(gzip_state, record))) { case OPKG_OPK_OK: - case OPKG_OPK_END: break; + case OPKG_OPK_END: case OPKG_OPK_ERROR: return OPKG_OPK_ERROR; } |