Windows requires non-Microsoft reparse points (identified by having bit
31 of the reparse tag clear) to have a 16-byte GUID following the regular
reparse point header. This GUID is not, and cannot, be included in the
"reparse data length" field.
The corrected validation logic allows applications to restore
non-Microsoft reparse points on files using libntfs-3g. Before,
ntfs_set_ntfs_reparse_data() would always fail with EINVAL.
---
libntfs-3g/reparse.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libntfs-3g/reparse.c b/libntfs-3g/reparse.c
index 7b96902..2198b49 100644
--- a/libntfs-3g/reparse.c
+++ b/libntfs-3g/reparse.c
@@ -422,8 +422,10 @@ static int ntfs_drive_letter(ntfs_volume *vol, ntfschar
letter)
/*
* Do some sanity checks on reparse data
*
- * The only general check is about the size (at least the tag must
- * be present)
+ * Microsoft reparse points have an 8-byte header whereas
+ * non-Microsoft reparse points have a 24-byte header. In each case,
+ * 'reparse_data_length' must equal the number of non-header bytes.
+ *
* If the reparse data looks like a junction point or symbolic
* link, more checks can be done.
*
@@ -441,7 +443,9 @@ static BOOL valid_reparse_data(ntfs_inode *ni,
ok = ni && reparse_attr
&& (size >= sizeof(REPARSE_POINT))
&& (((size_t)le16_to_cpu(reparse_attr->reparse_data_length)
- + sizeof(REPARSE_POINT)) == size);
+ + sizeof(REPARSE_POINT)
+ + ((reparse_attr->reparse_tag &
+ IO_REPARSE_TAG_IS_MICROSOFT) ? 0 : sizeof(GUID)))
== size);
if (ok) {
switch (reparse_attr->reparse_tag) {
case IO_REPARSE_TAG_MOUNT_POINT :
--
2.6.2
------------------------------------------------------------------------------
_______________________________________________
ntfs-3g-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel