From 3b05052885168a50852b86609a89f29d1c0c6d97 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 19 Nov 2014 21:41:37 -0600 Subject: [PATCH] lookup_table.c: Annotate potential unaligned memory access in lookup_stream() --- include/wimlib/unaligned.h | 1 + src/lookup_table.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/wimlib/unaligned.h b/include/wimlib/unaligned.h index d30c9f20..9d708065 100644 --- a/include/wimlib/unaligned.h +++ b/include/wimlib/unaligned.h @@ -34,5 +34,6 @@ store_##type##_unaligned(type val, void *p) \ DEFINE_UNALIGNED_TYPE(le16); DEFINE_UNALIGNED_TYPE(le32); DEFINE_UNALIGNED_TYPE(le64); +DEFINE_UNALIGNED_TYPE(size_t); #endif /* _WIMLIB_UNALIGNED_H */ diff --git a/src/lookup_table.c b/src/lookup_table.c index 8dc24109..3d2abf60 100644 --- a/src/lookup_table.c +++ b/src/lookup_table.c @@ -33,6 +33,7 @@ #include "wimlib/metadata.h" #include "wimlib/ntfs_3g.h" #include "wimlib/resource.h" +#include "wimlib/unaligned.h" #include "wimlib/util.h" #include "wimlib/write.h" @@ -377,7 +378,7 @@ lookup_stream(const struct wim_lookup_table *table, const u8 hash[]) struct wim_lookup_table_entry *lte; struct hlist_node *pos; - i = *(size_t*)hash % table->capacity; + i = load_size_t_unaligned(hash) % table->capacity; hlist_for_each_entry(lte, pos, &table->array[i], hash_list) if (hashes_equal(hash, lte->hash)) return lte; -- 2.43.0