Validated minimum size of mountpoint/symlink reparse points

valid_reparse_data() would read past the end of the reparse point buffer
if it was passed a malformed reparse point that had the tag for a
mountpoint or a symlink but had a data buffer smaller than expected.
Fix this by validating the buffer size.

(contributed by Eric Biggers)
This commit is contained in:
Jean-Pierre André 2017-02-11 10:00:34 +01:00
parent 3c5fb9b352
commit 376f4cbca7

View File

@ -446,6 +446,11 @@ static BOOL valid_reparse_data(ntfs_inode *ni,
if (ok) {
switch (reparse_attr->reparse_tag) {
case IO_REPARSE_TAG_MOUNT_POINT :
if (size < sizeof(REPARSE_POINT) +
sizeof(struct MOUNT_POINT_REPARSE_DATA)) {
ok = FALSE;
break;
}
mount_point_data = (const struct MOUNT_POINT_REPARSE_DATA*)
reparse_attr->reparse_data;
offs = le16_to_cpu(mount_point_data->subst_name_offset);
@ -458,6 +463,11 @@ static BOOL valid_reparse_data(ntfs_inode *ni,
ok = FALSE;
break;
case IO_REPARSE_TAG_SYMLINK :
if (size < sizeof(REPARSE_POINT) +
sizeof(struct SYMLINK_REPARSE_DATA)) {
ok = FALSE;
break;
}
symlink_data = (const struct SYMLINK_REPARSE_DATA*)
reparse_attr->reparse_data;
offs = le16_to_cpu(symlink_data->subst_name_offset);