ref: e6435a48f54c9f84eec99bb5f56c327ae59b9c1f
parent: ffc811b4e0b2a4618f857923c0ce235fd3996692
author: Kaho Ng <ngkaho1234@gmail.com>
date: Mon Feb 27 19:52:03 EST 2017
ext4_xattr: fix access violation if extra_isize is 0
--- a/src/ext4_xattr.c
+++ b/src/ext4_xattr.c
@@ -1434,6 +1434,8 @@
struct ext4_xattr_info i;
bool block_found = false;
ext4_fsblk_t orig_xattr_block;
+ size_t extra_isize =
+ ext4_inode_get_extra_isize(&fs->sb, inode_ref->inode);
i.name_index = name_index;
i.name = name;
@@ -1471,7 +1473,12 @@
} else {
try_insert:
- ret = ext4_xattr_set_entry(&i, &ibody_finder.s, false);
+ /* Only try to set entry in ibody if inode is sufficiently large */
+ if (extra_isize)
+ ret = ext4_xattr_set_entry(&i, &ibody_finder.s, false);
+ else
+ ret = ENOSPC;
+
if (ret == ENOSPC) {
if (!block_found) {
ret = ext4_xattr_block_set(inode_ref, &i, false);