diff options
author | Timo Teräs <timo.teras@iki.fi> | 2021-07-30 18:06:34 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-07-30 18:06:34 +0300 |
commit | 727ecc440c91e6dd4e658538cef0b14964dec195 (patch) | |
tree | f873eb22047b3724840409b4d230a97f8a40cf00 /src/extract_v3.c | |
parent | d3e71bb406239a5205163f9d8b31c4a5cac6f097 (diff) | |
download | apk-tools-727ecc440c91e6dd4e658538cef0b14964dec195.tar.gz apk-tools-727ecc440c91e6dd4e658538cef0b14964dec195.tar.bz2 apk-tools-727ecc440c91e6dd4e658538cef0b14964dec195.tar.xz apk-tools-727ecc440c91e6dd4e658538cef0b14964dec195.zip |
verify: support v3 packages
Diffstat (limited to 'src/extract_v3.c')
-rw-r--r-- | src/extract_v3.c | 26 |
1 files changed, 23 insertions, 3 deletions
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; } |