From 34d29fe0b0a9c5b70e5a7d6f0fb27786b4b81828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 9 Nov 2015 16:14:31 +0100 Subject: [PATCH] Fixed reparse data check for non-Microsoft tags 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. (Contributed by Eric Biggers) --- 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 7b96902c..2198b491 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 :