Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
8ab11dd5
Commit
8ab11dd5
authored
Sep 30, 2018
by
Gabriel DeBacker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue with path canonicalization for Win32 paths
parent
1621a37d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
src/win32/w32_util.c
+14
-2
tests/path/win32.c
+18
-0
No files found.
src/win32/w32_util.c
View file @
8ab11dd5
...
...
@@ -132,6 +132,8 @@ size_t git_win32__canonicalize_path(wchar_t *str, size_t len)
static
const
wchar_t
dosdevices_prefix
[]
=
L"
\\
\?\?
\\
"
;
static
const
wchar_t
nt_prefix
[]
=
L"
\\\\
?
\\
"
;
static
const
wchar_t
unc_prefix
[]
=
L"UNC
\\
"
;
static
const
wchar_t
unc_canonicalized_prefix
[]
=
L"
\\\\
"
;
size_t
to_advance
=
0
;
/* "\??\" -- DOS Devices prefix */
...
...
@@ -150,8 +152,18 @@ size_t git_win32__canonicalize_path(wchar_t *str, size_t len)
/* "\??\UNC\", "\\?\UNC\" -- UNC prefix */
if
(
to_advance
&&
len
>=
CONST_STRLEN
(
unc_prefix
)
&&
!
wcsncmp
(
str
+
to_advance
,
unc_prefix
,
CONST_STRLEN
(
unc_prefix
)))
{
to_advance
+=
CONST_STRLEN
(
unc_prefix
);
len
-=
CONST_STRLEN
(
unc_prefix
);
/**
* The proper Win32 path for a UNC share has "\\" at beginning of it
* and looks like "\\server\share\<folderStructure>".
* So, remove th UNC prefix, but leave room for a "\\"
*/
to_advance
+=
(
CONST_STRLEN
(
unc_prefix
)
-
CONST_STRLEN
(
unc_canonicalized_prefix
));
len
-=
(
CONST_STRLEN
(
unc_prefix
)
-
CONST_STRLEN
(
unc_canonicalized_prefix
));
/**
* Place a "\\" in the string so the result is "\\server\\share\<folderStructure>"
*/
memmove
(
str
+
to_advance
,
unc_canonicalized_prefix
,
CONST_STRLEN
(
unc_canonicalized_prefix
)
*
sizeof
(
wchar_t
));
}
if
(
to_advance
)
{
...
...
tests/path/win32.c
View file @
8ab11dd5
...
...
@@ -145,6 +145,22 @@ void test_canonicalize(const wchar_t *in, const wchar_t *expected)
#endif
}
void
test_path_git_win32__canonicalize_path
(
const
wchar_t
*
in
,
const
wchar_t
*
expected
)
{
#ifdef GIT_WIN32
git_win32_path
canonical
;
cl_assert
(
wcslen
(
in
)
<
MAX_PATH
);
wcscpy
(
canonical
,
in
);
cl_must_pass
(
git_win32__canonicalize_path
(
canonical
,
wcslen
(
in
)));
cl_assert_equal_wcs
(
expected
,
canonical
);
#else
GIT_UNUSED
(
in
);
GIT_UNUSED
(
expected
);
#endif
}
void
test_path_win32__canonicalize
(
void
)
{
#ifdef GIT_WIN32
...
...
@@ -186,6 +202,8 @@ void test_path_win32__canonicalize(void)
test_canonicalize
(
L"
\\\\
server
\\\\
share
\\\\
foo
\\\\
bar"
,
L"
\\\\
server
\\
share
\\
foo
\\
bar"
);
test_canonicalize
(
L"
\\\\
server
\\
share
\\
..
\\
foo"
,
L"
\\\\
server
\\
foo"
);
test_canonicalize
(
L"
\\\\
server
\\
..
\\
..
\\
share
\\
.
\\
foo"
,
L"
\\\\
server
\\
share
\\
foo"
);
test_path_git_win32__canonicalize_path
(
L"
\\\\
?
\\
UNC
\\
server
\\
C$
\\
folder"
,
L"
\\\\
server
\\
C$
\\
folder"
);
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment