lookup_table.c: Annotate potential unaligned memory access in lookup_stream()
authorEric Biggers <ebiggers3@gmail.com>
Thu, 20 Nov 2014 03:41:37 +0000 (21:41 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 20 Nov 2014 03:45:51 +0000 (21:45 -0600)
include/wimlib/unaligned.h
src/lookup_table.c

index d30c9f200704735df1c9d368cb4db5a9214b4c8a..9d70806529c0786e0ab7502e4654b6175c709213 100644 (file)
@@ -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 */
index 8dc24109f89ea16697abdfbc6ce6fc283c755e9c..3d2abf60539380b9ab3656cdfb72cff13f7d2777 100644 (file)
@@ -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;