summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-02-21 09:31:21 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-02-21 09:33:58 +0200
commitc054fbc11e9beca0d45285c3e1f448c81416c5ce (patch)
tree8884f1f2de291958f9c64d4536e052898ce2cded /src/database.c
parent271047cc930150a2972573625124b0c097ad322a (diff)
downloadapk-tools-c054fbc11e9beca0d45285c3e1f448c81416c5ce.tar.gz
apk-tools-c054fbc11e9beca0d45285c3e1f448c81416c5ce.tar.bz2
apk-tools-c054fbc11e9beca0d45285c3e1f448c81416c5ce.tar.xz
apk-tools-c054fbc11e9beca0d45285c3e1f448c81416c5ce.zip
db: fix unaligned memory access in csum_hash()
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/database.c b/src/database.c
index 2ca1286..06d1619 100644
--- a/src/database.c
+++ b/src/database.c
@@ -128,7 +128,9 @@ static unsigned long csum_hash(apk_blob_t csum)
{
/* Checksum's highest bits have the most "randomness", use that
* directly as hash */
- return *(unsigned long *) csum.ptr;
+ if (csum.len >= sizeof(uint32_t))
+ return get_unaligned32(csum.ptr);
+ return 0;
}
static const struct apk_hash_ops pkg_info_hash_ops = {