Whamcloud - gitweb
e2fsck: fix f_baddotdir failure on big-endian systems
authorTheodore Ts'o <tytso@mit.edu>
Wed, 28 Jul 2021 17:51:13 +0000 (13:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 28 Jul 2021 18:40:49 +0000 (14:40 -0400)
commit225e5d093b519f9dbe9fcaacd995426f0e5194f6
tree1917c5fc2b892c89ff2ce4ec7c4c0b95fb53dc7f
parent496669a2900e6be58dcf200b8ea1802a866ef3b8
e2fsck: fix f_baddotdir failure on big-endian systems

Commit 63f44aafb1f2 ("e2fsck: fix ".." more gracefully if possible")
changed the check_dot() function to try to avoid resetting the '..'
entry when the '.' entry is too large..  But if we do that, then on
big-endian systems, we need to try byte swapping the rest of the
directory entries, or else the f_baddotdir test will fail on
big-endian systems.

Also add a check to avoid UBSAN warning when there is not enough space
at the end of the directory block for a directory entry, and so we can
potentially overflow some pointer arithmetic when trying to byte swap
the remainder of the (negative) space in the directory block.

Fixes: 63f44aafb1f2 ("e2fsck: fix ".." more gracefully if possible")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass2.c