Checked expanded attribute does not overflow the space in use

When resizing an attribute, make sure the trailing data is moved in
the correct direction.
edge.strict_endians^2
Jean-Pierre André 2021-07-12 08:31:18 +02:00
parent 84478c4012
commit 68ead9b8fc
1 changed files with 7 additions and 0 deletions

View File

@ -4635,6 +4635,13 @@ int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size)
}
/* Move attributes following @a to their new location. */
if (((u8 *)m + old_size) < ((u8 *)a + attr_size)) {
ntfs_log_error("Attribute 0x%x overflows"
" from MFT record\n",
(int)le32_to_cpu(a->type));
errno = EIO;
return (-1);
}
memmove((u8 *)a + new_size, (u8 *)a + attr_size,
old_size - ((u8 *)a - (u8 *)m) - attr_size);