summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/extract_v2.c2
-rw-r--r--src/extract_v3.c26
2 files changed, 24 insertions, 4 deletions
diff --git a/src/extract_v2.c b/src/extract_v2.c
index 029a5e3..588e1e8 100644
--- a/src/extract_v2.c
+++ b/src/extract_v2.c
@@ -356,7 +356,7 @@ int apk_extract_v2(struct apk_extract_ctx *ectx, struct apk_istream *is)
apk_istream_gunzip_mpart(is, apk_sign_ctx_mpart_cb, &sctx),
apk_extract_v2_entry, ectx, apk_ctx_get_id_cache(ac));
if (r == -ECANCELED) r = 0;
- if (r == 0 && !ectx->is_package && !ectx->is_index)
+ if ((r == 0 || r == -APKE_SIGNATURE_UNTRUSTED || r == -APKE_EOF) && !ectx->is_package && !ectx->is_index)
r = ectx->ops->v2index ? -APKE_V2NDX_FORMAT : -APKE_V2PKG_FORMAT;
if (ectx->generate_identity) *ectx->identity = sctx.identity;
apk_sign_ctx_free(&sctx);
diff --git a/src/extract_v3.c b/src/extract_v3.c
index 156bcbc..21724ab 100644
--- a/src/extract_v3.c
+++ b/src/extract_v3.c
@@ -188,6 +188,25 @@ static int apk_extract_v3_data_block(struct adb *db, struct adb_block *b, struct
return apk_extract_v3_file(ectx, sz, is);
}
+static int apk_extract_v3_verify_meta(struct apk_extract_ctx *ectx, struct adb *db)
+{
+ return 0;
+}
+
+static int apk_extract_v3_verify_file(struct apk_extract_ctx *ectx, const struct apk_file_info *fi, struct apk_istream *is)
+{
+ if (is) {
+ apk_istream_read(is, 0, fi->size);
+ return apk_istream_close(is);
+ }
+ return 0;
+}
+
+static const struct apk_extract_ops extract_v3verify_ops = {
+ .v3meta = apk_extract_v3_verify_meta,
+ .file = apk_extract_v3_verify_file,
+};
+
int apk_extract_v3(struct apk_extract_ctx *ectx, struct apk_istream *is)
{
struct apk_ctx *ac = ectx->ac;
@@ -198,8 +217,8 @@ int apk_extract_v3(struct apk_extract_ctx *ectx, struct apk_istream *is)
int r;
if (IS_ERR(is)) return PTR_ERR(is);
- if (!ectx->ops || !ectx->ops->v3meta)
- return apk_istream_close_error(is, -APKE_FORMAT_NOT_SUPPORTED);
+ if (!ectx->ops) ectx->ops = &extract_v3verify_ops;
+ if (!ectx->ops->v3meta) return apk_istream_close_error(is, -APKE_FORMAT_NOT_SUPPORTED);
ectx->pctx = &ctx;
r = adb_m_process(&ctx.db, adb_decompress(is, 0),
@@ -211,6 +230,7 @@ int apk_extract_v3(struct apk_extract_ctx *ectx, struct apk_istream *is)
}
if (r == -ECANCELED) r = 0;
adb_free(&ctx.db);
- ectx->pctx = 0;
+ apk_extract_reset(ectx);
+
return r;
}