aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-23 11:41:10 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-23 11:41:10 +0300
commit042879f417fa1d0a0ab174b4c8f3847ee1f148b5 (patch)
treeb0913dd00f531ed839aa3c611a169bd71ccf88b7
parenta388f4bfa6e92a06d95de576aee94f2ae5695cfe (diff)
downloadapk-tools-042879f417fa1d0a0ab174b4c8f3847ee1f148b5.tar.bz2
apk-tools-042879f417fa1d0a0ab174b4c8f3847ee1f148b5.tar.xz
index: fully process archive when reading index for signature check
can't cancel an index reading or we lose signature checking.
-rw-r--r--src/database.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/database.c b/src/database.c
index 076f72f..bf0a0a6 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1146,7 +1146,7 @@ int apk_repository_update(struct apk_database *db, struct apk_repository *repo)
struct apkindex_ctx {
struct apk_database *db;
struct apk_sign_ctx sctx;
- int repo;
+ int repo, found;
};
static int load_apkindex(void *sctx, const struct apk_file_info *fi,
@@ -1161,11 +1161,12 @@ static int load_apkindex(void *sctx, const struct apk_file_info *fi,
if (strcmp(fi->name, "APKINDEX") != 0)
return 0;
+ ctx->found = 1;
bs = apk_bstream_from_istream(is);
apk_db_index_read(ctx->db, bs, ctx->repo);
bs->close(bs, NULL);
- return -ECANCELED;
+ return 0;
}
static int load_index(struct apk_database *db, struct apk_bstream *bs,
@@ -1179,15 +1180,14 @@ static int load_index(struct apk_database *db, struct apk_bstream *bs,
ctx.db = db;
ctx.repo = repo;
+ ctx.found = 0;
apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY, NULL);
is = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &ctx.sctx);
r = apk_tar_parse(is, load_apkindex, &ctx);
is->close(is);
apk_sign_ctx_free(&ctx.sctx);
- if (r == 0)
+ if (ctx.found == 0)
r = -ENOMSG;
- else if (r == -ECANCELED)
- r = 0;
} else {
bs = apk_bstream_from_istream(apk_bstream_gunzip(bs));
apk_db_index_read(db, bs, repo);