]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Do not preppend \\?\ if it is already there 714/head
authorJulien Finet <julien.finet@kitware.com>
Wed, 8 Jun 2016 14:39:52 +0000 (16:39 +0200)
committerJulien Finet <julien.finet@kitware.com>
Wed, 8 Jun 2016 14:39:52 +0000 (16:39 +0200)
If GetCurrentDirectory() returns \\?\C\a\path or
\\?\UNC\server\a\path, then adding \\?\ would not work.

libarchive/archive_write_disk_windows.c

index 800aa893f420a50570525defc19d8372ae7e820f..da76c54db5b60c95e654ebd82e927190d4d262a2 100644 (file)
@@ -468,9 +468,17 @@ permissive_name_w(struct archive_write_disk *a)
                return (-1);
        archive_wstring_ensure(&(a->_name_data), 4 + l + 1 + wcslen(wn) + 1);
        a->name = a->_name_data.s;
-       /* Prepend "\\?\" and drive name. */
-       archive_wstrncpy(&(a->_name_data), L"\\\\?\\", 4);
-       archive_wstrncat(&(a->_name_data), wsp, l);
+       /* Prepend "\\?\" and drive name if not already added. */
+       if (l > 3 && wsp[0] == L'\\' && wsp[1] == L'\\' &&
+               wsp[2] == L'?' && wsp[3] == L'\\')
+       {
+               archive_wstrncpy(&(a->_name_data), wsp, l);
+       }
+       else
+       {
+               archive_wstrncpy(&(a->_name_data), L"\\\\?\\", 4);
+               archive_wstrncat(&(a->_name_data), wsp, l);
+       }
        archive_wstrncat(&(a->_name_data), L"\\", 1);
        archive_wstrcat(&(a->_name_data), wn);
        a->name = a->_name_data.s;