From f154a8abf2b32f47894172a601ade789d083db6e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 5 Feb 2013 20:23:59 -0600 Subject: [PATCH] capture_ntfs_streams(): Fix reparse tag capture bug The reparse tag will be incorrectly left 0 if a reparse point data buffer is identical to an existing stream. Fix it. --- src/ntfs-apply.c | 1 + src/ntfs-capture.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ntfs-apply.c b/src/ntfs-apply.c index 31b84239..fcf141f5 100644 --- a/src/ntfs-apply.c +++ b/src/ntfs-apply.c @@ -338,6 +338,7 @@ static int apply_reparse_data(ntfs_inode *ni, const struct wim_dentry *dentry, u8 reparse_data_buf[8 + wim_resource_size(lte)]; u8 *p = reparse_data_buf; p = put_u32(p, dentry->d_inode->i_reparse_tag); /* ReparseTag */ + DEBUG("ReparseTag = %#x", dentry->d_inode->i_reparse_tag); p = put_u16(p, wim_resource_size(lte)); /* ReparseDataLength */ p = put_u16(p, 0); /* Reserved */ diff --git a/src/ntfs-capture.c b/src/ntfs-capture.c index b3f79eb4..9861523b 100644 --- a/src/ntfs-capture.c +++ b/src/ntfs-capture.c @@ -222,6 +222,7 @@ static int ntfs_attr_sha1sum(ntfs_inode *ni, ATTR_RECORD *ar, if (ntfs_attr_pread(na, 0, 8, buf) != 8) goto out_error; *reparse_tag_ret = le32_to_cpu(*(u32*)buf); + DEBUG("ReparseTag = %#x", *reparse_tag_ret); pos = 8; bytes_remaining -= 8; } @@ -298,6 +299,9 @@ static int capture_ntfs_streams(struct wim_dentry *dentry, ntfs_inode *ni, if (ret != 0) goto out_put_actx; + if (type == AT_REPARSE_POINT) + dentry->d_inode->i_reparse_tag = reparse_tag; + /* Make a lookup table entry for the stream, or use an existing * one if there's already an identical stream. */ lte = __lookup_resource(lookup_table, attr_hash); @@ -329,7 +333,6 @@ static int capture_ntfs_streams(struct wim_dentry *dentry, ntfs_inode *ni, lte->ntfs_loc = ntfs_loc; lte->resource_location = RESOURCE_IN_NTFS_VOLUME; if (type == AT_REPARSE_POINT) { - dentry->d_inode->i_reparse_tag = reparse_tag; ntfs_loc->is_reparse_point = true; lte->resource_entry.original_size = data_size - 8; lte->resource_entry.size = data_size - 8; -- 2.43.0