Validate attribute type in ntfs_inode_add_attr().

(Logical change 1.614)
This commit is contained in:
(none)!yura 2004-10-17 09:50:21 +00:00
parent c59b032f7e
commit 827ed37ec3

View File

@ -836,6 +836,22 @@ ntfs_attr *ntfs_inode_add_attr(ntfs_inode *ni, ATTR_TYPES type,
if (ni->nr_extents == -1) if (ni->nr_extents == -1)
ni = ni->base_ni; ni = ni->base_ni;
/* Validate attribute type. */
if (!ntfs_attr_find_in_attrdef(ni->vol, type)) {
if (errno == ENOENT) {
Dprintf("%s(): Invalid attribute type.\n",
__FUNCTION__);
errno = EINVAL;
return NULL;
} else {
err = errno;
Dprintf("%s(): ntfs_attr_find_in_attrdef failed.\n",
__FUNCTION__);
errno = err;
return NULL;
}
}
/* /*
* Determine resident or not will be new attribute. We add 8 to size in * Determine resident or not will be new attribute. We add 8 to size in
* non resident case for mapping pairs. * non resident case for mapping pairs.