From fd9c8d89e43b57149471d7af4378c3424242fe18 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 13 Apr 2023 08:23:57 -0400 Subject: ustar: Improve end detection --- 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; } -- cgit v0.9.1