]> wimlib.net Git - wimlib/blobdiff - src/win32_apply.c
path_is_root_of_drive(): Recognize \\?\-prefixed paths as being drive root
[wimlib] / src / win32_apply.c
index 010b9bee6171fdbd3027b2b9907ff22304a5cfaf..11104f24bc88404d2ba2b5cbc94b8a1b593fa140 100644 (file)
@@ -97,7 +97,7 @@ win32_extract_try_rpfix(u8 *rpbuf,
        stripped_nchars = ret;
        target = rpdata.substitute_name;
        target_nchars = rpdata.substitute_name_nbytes / sizeof(utf16lechar);
-       stripped_target = target + 6;
+       stripped_target = target + stripped_nchars;
        stripped_target_nchars = target_nchars - stripped_nchars;
 
        new_target = alloca((6 + extract_root_realpath_nchars +
@@ -106,8 +106,7 @@ win32_extract_try_rpfix(u8 *rpbuf,
        p = new_target;
        if (stripped_nchars == 6) {
                /* Include \??\ prefix if it was present before */
-               wmemcpy(p, L"\\??\\", 4);
-               p += 4;
+               p = wmempcpy(p, L"\\??\\", 4);
        }
 
        /* Print name excludes the \??\ if present. */
@@ -483,9 +482,12 @@ do_win32_extract_encrypted_stream(const wchar_t *path,
 static bool
 path_is_root_of_drive(const wchar_t *path)
 {
-       if (!*path)
+       if (*path == L'\0')
                return false;
 
+       if (!wcsncmp(path, L"\\\\?\\", 4))
+               path += 4;
+
        if (*path != L'/' && *path != L'\\') {
                if (*(path + 1) == L':')
                        path += 2;
@@ -1236,6 +1238,7 @@ win32_do_apply_dentry(const wchar_t *output_path,
            !(args->vol_flags & FILE_SUPPORTS_REPARSE_POINTS))
        {
                WARNING("Not extracting reparse point \"%ls\"", output_path);
+               dentry->not_extracted = 1;
        } else {
                /* Create the file, directory, or reparse point, and extract the
                 * data streams. */
@@ -1259,7 +1262,7 @@ win32_do_apply_dentry(const wchar_t *output_path,
                        /* Save extracted path for a later call to
                         * CreateHardLinkW() if this inode has multiple links.
                         * */
-                       inode->i_extracted_file = WSTRDUP(output_path);
+                       inode->i_extracted_file = WCSDUP(output_path);
                        if (!inode->i_extracted_file)
                                return WIMLIB_ERR_NOMEM;
                }
@@ -1278,13 +1281,6 @@ win32_do_apply_dentry_timestamps(const wchar_t *path,
        HANDLE h;
        const struct wim_inode *inode = dentry->d_inode;
 
-       if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT &&
-           !(args->vol_flags & FILE_SUPPORTS_REPARSE_POINTS))
-       {
-               /* Skip reparse points not extracted */
-               return 0;
-       }
-
        /* Windows doesn't let you change the timestamps of the root directory
         * (at least on FAT, which is dumb but expected since FAT doesn't store
         * any metadata about the root directory...) */