Whamcloud - gitweb
lib/blkid: fix unaligned access to hfs_mdb
authorEric Biggers <ebiggers@google.com>
Sat, 21 Jan 2023 20:32:00 +0000 (12:32 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 27 Jan 2023 17:33:59 +0000 (12:33 -0500)
commitae92b8f549cfc02f2231b3639ddf8a1b50b379ad
treebf8d82c8c3c9525f689075a0ec0567e53c151a90
parentc49ed1fe5fae98fa6272fdb205f34cef4c63aeb3
lib/blkid: fix unaligned access to hfs_mdb

With -Wall, gcc warns:

      ./probe.c:1209:42: error: taking address of packed member of
               'struct hfs_mdb' may result in an unaligned pointer value

This seems to be a real unaligned memory access bug, as the offset of
the 64-bit value from the start of the buffer is 116, which is not a
multiple of 8.  Fix it by using memcpy().

Do the same for hfsplus to fix the same warning, though in that case the
offset is a multiple of 8 so it was defined behavior.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/blkid/probe.c