Skip to content

Fix issue #4821 with path canonicalization for Win32 paths#4825

Merged
ethomson merged 2 commits into
libgit2:masterfrom
GabeDeBacker:master
Oct 20, 2018
Merged

Fix issue #4821 with path canonicalization for Win32 paths#4825
ethomson merged 2 commits into
libgit2:masterfrom
GabeDeBacker:master

Conversation

@GabeDeBacker
Copy link
Copy Markdown
Contributor

This pull request fixes issue #4821.

This issue occurs when a user has a reparse point (symbol link) for their global %userprofile%.gitconfig file the points to a Windows UNC share.

The p_stat function correctly determines that the path is a symbolic link and uses the getfinalpath_w function to Windows file path that can be used with GetFileAttributesEx. The getfinalypath_w ultimately uses git_win32__canonicalize_path to strip any prefixes that may have been returned by GetFinalPathNameByHandleW (for example "\\?\.\UNC\). However, when a UNC path is converted, the beginning "\\" characters where incorrectly stripped from the path, leaving an incorrect file name.

This libgit to be unable to locate and read the .gitconfig file.

Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your changes! I cannot really argue whether the change is correct or not, I defer that to @ethomson, as he's more familiar with Windows systems. I have some proposals though for improving the added tests.

Anyway, thanks for working on this!

Comment thread tests/path/win32.c Outdated
Comment thread tests/path/win32.c Outdated
Comment thread src/win32/w32_util.c
@ethomson
Copy link
Copy Markdown
Member

ethomson commented Oct 5, 2018

/rebuild

@libgit2-azure-pipelines
Copy link
Copy Markdown

Okay, @ethomson, I started to rebuild this pull request.

Comment thread tests/path/win32.c
#endif
}

void static test_canonicalize_path(const wchar_t *in, const wchar_t *expected)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These here are switched ;)

Suggested change
void static test_canonicalize_path(const wchar_t *in, const wchar_t *expected)
static void test_canonicalize_path(const wchar_t *in, const wchar_t *expected)

Comment thread tests/path/win32.c
}

void test_canonicalize(const wchar_t *in, const wchar_t *expected)
void static test_canonicalize(const wchar_t *in, const wchar_t *expected)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same over here:

Suggested change
void static test_canonicalize(const wchar_t *in, const wchar_t *expected)
static void test_canonicalize(const wchar_t *in, const wchar_t *expected)

@pks-t
Copy link
Copy Markdown
Member

pks-t commented Oct 19, 2018

Oh, just saw that Ed took this over. So you probably don't have to do anything, he's fixed your commits and they'll be merged as part of #4852 :)

@ethomson ethomson merged commit 3f096ca into libgit2:master Oct 20, 2018
@ethomson
Copy link
Copy Markdown
Member

Thanks again @GabeDeBacker for the fix and especially for the tests! 😀

Hope you don't mind that I wanted to fix up some other issues in our code base that I noticed while reviewing this. (They were obviously our problems, not problems in this PR, but they confused me during the review so I wanted to get them cleaned up.)

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants