Whamcloud - gitweb
libext2fs: initialize i_extra_isize when writing EAs
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 27 Jan 2015 15:59:19 +0000 (10:59 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 27 Jan 2015 15:59:19 +0000 (10:59 -0500)
commit366d299fe73f6e93b4182ed65d72d26705a378da
tree7974fabaa08fa69f37f5bf7ee05c38cd8b756615
parentd0bc2c88245224e5384ac022ac0ce6b9aae03c12
libext2fs: initialize i_extra_isize when writing EAs

If i_extra_isize is zero when we try to write extended attributes,
we'll end up writing the EA magic into the i_extra_isize field, which
causes a subsequent crash on big endian systems (when we try to write
0xEA02 bytes past the inode!).  Therefore when the field is zero, set
i_extra_isize to the desired extra_isize size, zero those bytes, and
write the EAs after the end of the extended inode.

v2: Don't bother if we have 128b inodes, and ensure that the value
is 32b-aligned so that the EA magic starts on a 32b boundary.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ext_attr.c
tests/f_write_ea_no_extra_isize/expect.1 [new file with mode: 0644]
tests/f_write_ea_no_extra_isize/expect.2 [new file with mode: 0644]
tests/f_write_ea_no_extra_isize/image.gz [new file with mode: 0644]
tests/f_write_ea_no_extra_isize/name [new file with mode: 0644]