summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apk_archive.h7
-rw-r--r--src/archive.c11
-rw-r--r--src/database.c9
-rw-r--r--src/package.c2
-rw-r--r--src/verify.c2
5 files changed, 19 insertions, 12 deletions
diff --git a/src/apk_archive.h b/src/apk_archive.h
index a0a289a..320db5e 100644
--- a/src/apk_archive.h
+++ b/src/apk_archive.h
@@ -20,8 +20,11 @@ typedef int (*apk_archive_entry_parser)(void *ctx,
const struct apk_file_info *ae,
struct apk_istream *istream);
-int apk_tar_parse(struct apk_istream *, apk_archive_entry_parser parser, void *ctx);
-int apk_tar_write_entry(struct apk_ostream *, const struct apk_file_info *ae, char *data);
+int apk_tar_parse(struct apk_istream *,
+ apk_archive_entry_parser parser, void *ctx,
+ int soft_checksums);
+int apk_tar_write_entry(struct apk_ostream *, const struct apk_file_info *ae,
+ char *data);
int apk_tar_write_padding(struct apk_ostream *, const struct apk_file_info *ae);
int apk_archive_entry_extract(const struct apk_file_info *ae,
diff --git a/src/archive.c b/src/archive.c
index 68ec287..dca99fd 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -114,7 +114,7 @@ static void tar_entry_close(void *stream)
}
int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
- void *ctx)
+ void *ctx, int soft_checksums)
{
struct apk_file_info entry;
struct apk_tar_entry_istream teis = {
@@ -152,6 +152,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
.device = makedev(GET_OCTAL(buf.devmajor),
GET_OCTAL(buf.devminor)),
};
+ teis.csum = NULL;
switch (buf.typeflag) {
case 'L':
@@ -170,8 +171,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
di->size <= sizeof(entry.csum.data)) {
entry.csum.type = di->size;
memcpy(entry.csum.data, di->digest, di->size);
- teis.csum = NULL;
- } else {
+ } else if (soft_checksums) {
teis.csum = &entry.csum;
}
break;
@@ -202,7 +202,10 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
entry.name = strdup(buf.name);
/* callback parser function */
- EVP_DigestInit_ex(&teis.mdctx, apk_default_checksum(), NULL);
+ if (teis.csum != NULL)
+ EVP_DigestInit_ex(&teis.mdctx,
+ apk_default_checksum(), NULL);
+
r = parser(ctx, &entry, &teis.is);
free(entry.name);
if (r != 0)
diff --git a/src/database.c b/src/database.c
index 720b7b0..efa91b4 100644
--- a/src/database.c
+++ b/src/database.c
@@ -706,7 +706,8 @@ static int apk_db_read_state(struct apk_database *db, int flags)
if (!(flags & APK_OPENF_NO_SCRIPTS)) {
is = apk_istream_from_file("var/lib/apk/scripts.tar");
if (is != NULL) {
- apk_tar_parse(is, apk_read_script_archive_entry, db);
+ apk_tar_parse(is, apk_read_script_archive_entry, db,
+ FALSE);
} else {
is = apk_istream_from_file("var/lib/apk/scripts");
if (is != NULL)
@@ -1119,7 +1120,7 @@ int apk_cache_download(struct apk_database *db, struct apk_checksum *csum,
apk_sign_ctx_init(&sctx, APK_SIGN_VERIFY, NULL);
is = apk_bstream_gunzip_mpart(apk_bstream_from_file(tmp2),
apk_sign_ctx_mpart_cb, &sctx);
- r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx);
+ r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, FALSE);
is->close(is);
apk_sign_ctx_free(&sctx);
if (r != 0) {
@@ -1224,7 +1225,7 @@ static int load_index(struct apk_database *db, struct apk_bstream *bs,
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);
+ r = apk_tar_parse(is, load_apkindex, &ctx, FALSE);
is->close(is);
apk_sign_ctx_free(&ctx.sctx);
if (ctx.found == 0)
@@ -1639,7 +1640,7 @@ static int apk_db_unpack_pkg(struct apk_database *db,
};
apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY_IDENTITY, &newpkg->csum);
tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &ctx.sctx);
- r = apk_tar_parse(tar, apk_db_install_archive_entry, &ctx);
+ r = apk_tar_parse(tar, apk_db_install_archive_entry, &ctx, TRUE);
apk_sign_ctx_free(&ctx.sctx);
tar->close(tar);
diff --git a/src/package.c b/src/package.c
index bf5b889..43ce646 100644
--- a/src/package.c
+++ b/src/package.c
@@ -713,7 +713,7 @@ int apk_pkg_read(struct apk_database *db, const char *file,
ctx.pkg->size = fi.size;
tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, sctx);
- r = apk_tar_parse(tar, read_info_entry, &ctx);
+ r = apk_tar_parse(tar, read_info_entry, &ctx, FALSE);
tar->close(tar);
if (r < 0 && r != -ECANCELED)
goto err;
diff --git a/src/verify.c b/src/verify.c
index 05ded17..9aaf8ae 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -25,7 +25,7 @@ static int verify_main(void *ctx, int argc, char **argv)
apk_sign_ctx_init(&sctx, APK_SIGN_VERIFY, NULL);
is = apk_bstream_gunzip_mpart(apk_bstream_from_file(argv[i]),
apk_sign_ctx_mpart_cb, &sctx);
- r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx);
+ r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, FALSE);
is->close(is);
ok = sctx.control_verified && sctx.data_verified;
if (apk_verbosity >= 1)