summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-30 11:55:59 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-30 11:55:59 +0300
commitc1fe6d08f3ba77bf13b098216fc5e5bcd4ba23f7 (patch)
treeca38a4df58d627d6b1973e93ff810ac27abde7ea /src/database.c
parent02cb0d2f8f3fa7e2bc8005160f0baec81bed69d2 (diff)
downloadapk-tools-c1fe6d08f3ba77bf13b098216fc5e5bcd4ba23f7.tar.gz
apk-tools-c1fe6d08f3ba77bf13b098216fc5e5bcd4ba23f7.tar.bz2
apk-tools-c1fe6d08f3ba77bf13b098216fc5e5bcd4ba23f7.tar.xz
apk-tools-c1fe6d08f3ba77bf13b098216fc5e5bcd4ba23f7.zip
db: fix checksum storing to db
also take precautions in audit code if the db is missing the checksum.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c
index 968d55e..16ae94b 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1458,6 +1458,7 @@ static int apk_db_install_archive_entry(void *_ctx,
diri->dir->name, file->name);
r = apk_archive_entry_extract(ae, is, alt_name,
extract_cb, ctx);
+ memcpy(&file->csum, &ae->csum, sizeof(file->csum));
} else {
if (apk_verbosity >= 3)
apk_message("%s", ae->name);
@@ -1502,7 +1503,8 @@ static void apk_db_purge_pkg(struct apk_database *db, struct apk_package *pkg,
hash = apk_blob_hash_seed(key.filename, diri->dir->hash);
if (!(diri->dir->flags & APK_DBDIRF_PROTECTED) ||
(apk_flags & APK_PURGE) ||
- (apk_file_get_info(name, file->csum.type, &fi) == 0 &&
+ (file->csum.type != APK_CHECKSUM_NONE &&
+ apk_file_get_info(name, file->csum.type, &fi) == 0 &&
apk_checksum_compare(&file->csum, &fi.csum) == 0))
unlink(name);
if (apk_verbosity >= 3)
@@ -1565,6 +1567,7 @@ static void apk_db_migrate_files(struct apk_database *db,
if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
(r == 0) &&
(ofile == NULL ||
+ ofile->csum.type == APK_CHECKSUM_NONE ||
apk_checksum_compare(&ofile->csum, &fi.csum) != 0)) {
/* Protected directory, with file without
* db entry, or local modifications.
@@ -1575,7 +1578,8 @@ static void apk_db_migrate_files(struct apk_database *db,
ofile->csum.type != file->csum.type)
apk_file_get_info(name, file->csum.type, &fi);
if ((apk_flags & APK_CLEAN_PROTECTED) ||
- apk_checksum_compare(&file->csum, &fi.csum) == 0)
+ (file->csum.type != APK_CHECKSUM_NONE &&
+ apk_checksum_compare(&file->csum, &fi.csum) == 0))
unlink(tmpname);
} else {
/* Overwrite the old file */