The misaligned uint16_t loads can come only form a corrupt metadata.
Found by OSS-Fuzz by cryptsetup project fuzzers (issue
507641687).
Signed-off-by: Milan Broz <gmazyland@gmail.com>
keylengths = (uint16_t *) ((uint8_t *) bn + keylengths_offset);
values = (int64_t *) ((uint8_t *) bn + values_offset);
+ /* Misaligned offset comes only from corrupt metadata. */
+ if ((uintptr_t) keylengths % sizeof(*keylengths))
+ return -ENOENT; /* Corrupt? */
+
first = 0;
mid = 0;
last = all_key_count - 1;