Perform a little more sanity checking of EA value offsets so that we
don't crash while trying to load things from the filesystem.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
ec EXT2_ET_INODE_IS_GARBAGE,
"Inode seems to contain garbage"
+ec EXT2_ET_EA_BAD_VALUE_OFFSET,
+ "Extended attribute has an invalid value offset"
+
end
void *ptr;
unsigned int remain, prefix_len;
errcode_t err;
+ unsigned int values_size = storage_size +
+ ((char *)entries - (char *)value_start);
x = handle->attrs;
while (x->name)
if (entry->e_value_size > remain)
return EXT2_ET_EA_BAD_VALUE_SIZE;
+ if (entry->e_value_offs + entry->e_value_size > values_size)
+ return EXT2_ET_EA_BAD_VALUE_OFFSET;
+
/* e_value_block must be 0 in inode's ea */
if (entry->e_value_block != 0)
return EXT2_ET_BAD_EA_BLOCK_NUM;