]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
libext2fs: provide functions to safely access name_len and file_type
authorJan Kara <jack@suse.cz>
Sat, 8 Jun 2013 15:26:14 +0000 (11:26 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 8 Jun 2013 21:03:05 +0000 (17:03 -0400)
commit70f4632b626e3db94dd02c9dc9b4e643ffb0d048
tree6f7ad3c02d23f684771c8144e393670543c53533
parentbd78b1dae99b0f0d3c5456478c320f5ac0a98584
libext2fs: provide functions to safely access name_len and file_type

Accessing name_len (and file_type) in ext4_dir_entry structure is
somewhat problematic because on big endian architecture we need to now
whether we are really dealing with ext4_dir_entry (which has u16
name_len which needs byte swapping) or ext4_dir_entry_2 (which has u8
name_len which must not be byte swapped).

Currently the code is somewhat surprising and name_len is always
treated as u16 and byte swapped (flag EXT2_DIRBLOCK_V2_STRUCT isn't
ever used) and then masking of name_len is used to access real
name_len or file_type. Doing things this way in applications using
libext2fs is unexpected to say the least (more natural is to type
struct ext4_dir_entry * to struct ext4_dir_entry_2 * but that gives
wrong results on big endian architectures. So provide helper functions
that give endian-safe access to these fields. Also convert users in
e2fsprogs to use these functions.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
21 files changed:
debugfs/debugfs.c
debugfs/dump.c
debugfs/filefrag.c
debugfs/htree.c
debugfs/ls.c
debugfs/ncheck.c
e2fsck/message.c
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/pass3.c
e2fsck/rehash.c
lib/ext2fs/dir_iterate.c
lib/ext2fs/ext2_fs.h
lib/ext2fs/ext2fs.h
lib/ext2fs/get_pathname.c
lib/ext2fs/link.c
lib/ext2fs/lookup.c
lib/ext2fs/newdir.c
lib/ext2fs/unlink.c
misc/tune2fs.c
resize/resize2fs.c