@@ -501,36 +501,31 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx,
goto fix;
}
- while (remain >= sizeof(struct ext2_ext_attr_entry) &&
- !EXT2_EXT_IS_LAST_ENTRY(entry)) {
+ while (!EXT2_EXT_IS_LAST_ENTRY(entry)) {
__u32 hash;
- if (region_allocate(region, (char *)entry - (char *)header,
- EXT2_EXT_ATTR_LEN(entry->e_name_len))) {
- problem = PR_1_INODE_EA_ALLOC_COLLISION;
- goto fix;
- }
-
- /* header eats this space */
- remain -= sizeof(struct ext2_ext_attr_entry);
-
- /* is attribute name valid? */
- if (EXT2_EXT_ATTR_SIZE(entry->e_name_len) > remain) {
+ /* entry->e_name_len is within the first four bytes */
+ if (EXT2_EXT_ATTR_LEN(entry->e_name_len) > remain) {
pctx->num = entry->e_name_len;
problem = PR_1_ATTR_NAME_LEN;
goto fix;
}
+ remain -= EXT2_EXT_ATTR_LEN(entry->e_name_len);
- /* attribute len eats this space */
- remain -= EXT2_EXT_ATTR_SIZE(entry->e_name_len);
+ if (region_allocate(region, (char *)entry - (char *)header,
+ EXT2_EXT_ATTR_LEN(entry->e_name_len))) {
+ problem = PR_1_INODE_EA_ALLOC_COLLISION;
+ goto fix;
+ }
if (entry->e_value_inum == 0) {
/* check value size */
- if (entry->e_value_size > remain) {
+ if (EXT2_EXT_ATTR_SIZE(entry->e_value_size) > remain) {
pctx->num = entry->e_value_size;
problem = PR_1_ATTR_VALUE_SIZE;
goto fix;
}
+ remain -= EXT2_EXT_ATTR_SIZE(entry->e_value_size);
if (entry->e_value_size &&
region_allocate(region,
@@ -571,11 +566,6 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx,
ea_ibody_quota->inodes++;
}
- /* If EA value is stored in external inode then it does not
- * consume space here */
- if (entry->e_value_inum == 0)
- remain -= entry->e_value_size;
-
entry = EXT2_EXT_ATTR_NEXT(entry);
}
@@ -1,7 +1,8 @@
Pass 1: Checking inodes, blocks, and sizes
Inode 12 extended attribute is corrupt (allocation collision). Clear? yes
-Inode 13 extended attribute is corrupt (allocation collision). Clear? yes
+Extended attribute in inode 13 has a namelen (98) which is invalid
+Clear? yes
Inode 14 extended attribute is corrupt (allocation collision). Clear? yes