]> wimlib.net Git - wimlib/blobdiff - src/win32_capture.c
win32_capture: correctly handle unspecified security IDs in MFT
[wimlib] / src / win32_capture.c
index d6be1124204312a73152fa87e376cf2263631646..786756f781a74b1ac94f7854633d9b8af00b43fb 100644 (file)
@@ -856,7 +856,7 @@ winnt_rpfix_progress(struct capture_params *params, const wchar_t *path,
        wmemcpy(print_name0, link->print_name, print_name_nchars);
        print_name0[print_name_nchars] = L'\0';
 
-       params->progress.scan.cur_path = printable_path(path);
+       params->progress.scan.cur_path = path;
        params->progress.scan.symlink_target = print_name0;
        return do_capture_progress(params, scan_status, NULL);
 }
@@ -1755,7 +1755,7 @@ retry_open:
        }
 
 out_progress:
-       ctx->params->progress.scan.cur_path = printable_path(full_path);
+       ctx->params->progress.scan.cur_path = full_path;
        if (likely(root))
                ret = do_capture_progress(ctx->params, WIMLIB_SCAN_DENTRY_OK, inode);
        else
@@ -2477,6 +2477,9 @@ security_map_lookup(struct security_map *map, u32 disk_security_id)
        struct security_map_node tmp;
        const struct avl_tree_node *res;
 
+       if (disk_security_id == 0)  /* No on-disk security ID; uncacheable  */
+               return -1;
+
        tmp.disk_security_id = disk_security_id;
        res = avl_tree_lookup_node(map->root, &tmp.index_node,
                                   _avl_cmp_security_map_nodes);
@@ -2491,6 +2494,9 @@ security_map_insert(struct security_map *map, u32 disk_security_id,
 {
        struct security_map_node *node;
 
+       if (disk_security_id == 0)  /* No on-disk security ID; uncacheable  */
+               return 0;
+
        node = MALLOC(sizeof(*node));
        if (!node)
                return WIMLIB_ERR_NOMEM;
@@ -2643,22 +2649,22 @@ generate_wim_structures_recursive(struct wim_dentry **root_ret,
        ns = FIRST_STREAM(ni);
        for (u32 i = 0; i < ni->num_streams; i++) {
                struct windows_file *windows_file;
-               size_t stream_name_nchars;
 
+               /* Reference the stream by path if it's a named data stream, or
+                * if the volume doesn't support "open by file ID", or if the
+                * application hasn't explicitly opted in to "open by file ID".
+                * Otherwise, only save the inode number (file ID).  */
                if (*ns->name ||
-                   !(ctx->vol_flags & FILE_SUPPORTS_OPEN_BY_FILE_ID))
+                   !(ctx->vol_flags & FILE_SUPPORTS_OPEN_BY_FILE_ID) ||
+                   !(ctx->params->add_flags & WIMLIB_ADD_FLAG_FILE_PATHS_UNNEEDED))
                {
-                       /* Named data stream: reference by path  */
-                       stream_name_nchars = wcslen(ns->name);
                        windows_file = alloc_windows_file(path,
                                                          path_nchars,
                                                          ns->name,
-                                                         stream_name_nchars,
+                                                         wcslen(ns->name),
                                                          ctx->snapshot,
                                                          false);
                } else {
-                       /* Unamed data stream: reference by file ID (inode number)  */
-                       stream_name_nchars = 0;
                        windows_file = alloc_windows_file_for_file_id(ni->ino,
                                                                      path,
                                                                      ctx->params->capture_root_nchars + 1,
@@ -2714,7 +2720,7 @@ generate_wim_structures_recursive(struct wim_dentry **root_ret,
        }
 
 out_progress:
-       ctx->params->progress.scan.cur_path = printable_path(path);
+       ctx->params->progress.scan.cur_path = path;
        if (likely(root))
                ret = do_capture_progress(ctx->params, WIMLIB_SCAN_DENTRY_OK, inode);
        else