summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorthibault.ferrante <thibault.ferrante@gmail.com>2021-01-07 17:21:36 +0100
committerTimo Teräs <timo.teras@iki.fi>2021-01-11 11:31:30 +0200
commit39f5bfd26ab10a754a566fcd238ca2cac5916f91 (patch)
tree364d5d2a8d48ef0467e6dc667d5a5d44761fded6 /src/database.c
parentd438cdfbeb13b0f38c0bef321fc767926df0e4e1 (diff)
downloadapk-tools-39f5bfd26ab10a754a566fcd238ca2cac5916f91.tar.gz
apk-tools-39f5bfd26ab10a754a566fcd238ca2cac5916f91.tar.bz2
apk-tools-39f5bfd26ab10a754a566fcd238ca2cac5916f91.tar.xz
apk-tools-39f5bfd26ab10a754a566fcd238ca2cac5916f91.zip
database: Propagate errors when loading an APKINDEX
In case of failure when loading an APKINDEX, no errors are propagated to the user which may uncorrectly interpret the current problem.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/database.c b/src/database.c
index bbf072e..b21737a 100644
--- a/src/database.c
+++ b/src/database.c
@@ -895,17 +895,18 @@ int apk_db_index_read(struct apk_database *db, struct apk_istream *is, int repo)
}
if (APK_BLOB_IS_NULL(l)) goto bad_entry;
}
- apk_istream_close(is);
- return 0;
+
+ return apk_istream_close(is);
old_apk_tools:
/* Installed db should not have unsupported fields */
apk_error("This apk-tools is too old to handle installed packages");
+ is->err = -EAPKFORMAT;
goto err;
bad_entry:
apk_error("FDB format error (line %d, entry '%c')", lineno, field);
+ is->err = -EAPKFORMAT;
err:
- apk_istream_close(is);
- return -1;
+ return apk_istream_close(is);
}
static void apk_blob_push_db_acl(apk_blob_t *b, char field, struct apk_db_acl *acl)
@@ -2192,10 +2193,10 @@ static int load_apkindex(void *sctx, const struct apk_file_info *fi,
repo->description = apk_blob_from_istream(is, fi->size);
} else if (strcmp(fi->name, "APKINDEX") == 0) {
ctx->found = 1;
- apk_db_index_read(ctx->db, is, ctx->repo);
+ r = apk_db_index_read(ctx->db, is, ctx->repo);
}
- return 0;
+ return r;
}
static int load_index(struct apk_database *db, struct apk_istream *is,