- u32 owner_offset, group_offset, dacl_offset, sacl_offset;
- bool owner_valid, group_valid;
- size_t size = *size_p;
- const wimlib_SECURITY_DESCRIPTOR_RELATIVE *desc =
- (const wimlib_SECURITY_DESCRIPTOR_RELATIVE*)_desc;
- wimlib_SECURITY_DESCRIPTOR_RELATIVE *desc_new;
- u32 sid_offset;
- const wimlib_SID *owner, *group, *sid;
-
- /* Don't attempt to fix clearly invalid security descriptors. */
- if (size < sizeof(wimlib_SECURITY_DESCRIPTOR_RELATIVE))
- return (u8*)_desc;
-
- if (le16_to_cpu(desc->control) & wimlib_SE_DACL_PRESENT)
- dacl_offset = le32_to_cpu(desc->dacl_offset);
- else
- dacl_offset = 0;
-
- if (le16_to_cpu(desc->control) & wimlib_SE_SACL_PRESENT)
- sacl_offset = le32_to_cpu(desc->sacl_offset);
- else
- sacl_offset = 0;
-
- /* Check if the security descriptor will be affected by one of the bugs.
- * If not, do nothing and return.
- *
- * Note: HAVE_NTFS_MNT_RDONLY is defined if libntfs-3g is
- * version 2013.1.13 or later. */
- if (!(
- #if !defined(HAVE_NTFS_MNT_RDONLY)
- (sacl_offset != 0 && sacl_offset == size - sizeof(wimlib_ACL)) ||
- #endif
- (dacl_offset != 0 && dacl_offset == size - sizeof(wimlib_ACL))))
- return (u8*)_desc;
-
- owner_offset = le32_to_cpu(desc->owner_offset);
- group_offset = le32_to_cpu(desc->group_offset);
- owner = (const wimlib_SID*)((const u8*)desc + owner_offset);
- group = (const wimlib_SID*)((const u8*)desc + group_offset);
-
- /* We'll try to move the owner or group SID to the end of the security
- * descriptor to avoid the bug. This is only possible if at least one
- * is valid. */
- owner_valid = (owner_offset != 0) &&
- (owner_offset % 4 == 0) &&
- (owner_offset <= size - sizeof(SID)) &&
- (owner_offset + sid_size(owner) <= size) &&
- (owner_offset >= sizeof(wimlib_SECURITY_DESCRIPTOR_RELATIVE));
- group_valid = (group_offset != 0) &&
- (group_offset % 4 == 0) &&
- (group_offset <= size - sizeof(SID)) &&
- (group_offset + sid_size(group) <= size) &&
- (group_offset >= sizeof(wimlib_SECURITY_DESCRIPTOR_RELATIVE));
- if (owner_valid) {
- sid = owner;
- } else if (group_valid) {
- sid = group;
+ struct wim_dentry *one_dentry = inode_first_extraction_dentry(inode);
+ ntfschar *stream_name;
+ size_t stream_name_nchars;
+ ntfs_attr *na;
+
+ if (unlikely(strm->stream_type == STREAM_TYPE_REPARSE_POINT)) {
+
+ if (blob->size > REPARSE_DATA_MAX_SIZE) {
+ ERROR("Reparse data of \"%s\" has size "
+ "%"PRIu64" bytes (exceeds %u bytes)",
+ dentry_full_path(one_dentry),
+ blob->size, REPARSE_DATA_MAX_SIZE);
+ return WIMLIB_ERR_INVALID_REPARSE_DATA;
+ }
+ ctx->reparse_ptr = ctx->rpbuf.rpdata;
+ ctx->ntfs_reparse_inodes[ctx->num_reparse_inodes] = ni;
+ ctx->wim_reparse_inodes[ctx->num_reparse_inodes] = inode;
+ ctx->num_reparse_inodes++;
+ return 0;
+ }
+
+ /* It's a data stream (may be unnamed or named). */
+ wimlib_assert(strm->stream_type == STREAM_TYPE_DATA);
+
+ if (unlikely(stream_is_named(strm))) {
+ stream_name = strm->stream_name;
+ stream_name_nchars = utf16le_len_chars(stream_name);
+
+ if (ntfs_attr_add(ni, AT_DATA, stream_name,
+ stream_name_nchars, NULL, 0))
+ {
+ ERROR_WITH_ERRNO("Failed to create named data stream of \"%s\"",
+ dentry_full_path(one_dentry));
+ return WIMLIB_ERR_NTFS_3G;
+ }