Skip to content

Repository ownership validation does not skip %(prefix)/ on Windows #6737

@csware

Description

@csware

Reproduction steps

Use Windows, open a repository on a network share.
Whitelist that directory with a prefix of %(prefix)/

Based on the Git error message %(prefix)/ should be used for network shares, but nowadays (Git 2.43) it also works without... I asked which one is the recommended way.

The stripped test_path is never used:

if (strncmp(test_path, "%(prefix)//", strlen("%(prefix)//")) == 0)
test_path += strlen("%(prefix)/");
else if (strncmp(test_path, "//", 2) == 0 &&
strncmp(test_path, "//wsl.localhost/", strlen("//wsl.localhost/")) != 0)
test_path++;
#endif
if (strcmp(data->tmp.ptr, data->repo_path) == 0)
*data->is_safe = true;

PR #6668 contained a working fix (which requires %(prefix)/ for network shares), but the changes applied to main (commit 516749f) are incomplete (the latest version of that PR also avoided additional copies).

Expected behavior

The safe.directory exception is accepted

Actual behavior

The safe.directory exception doesn't match

Version of libgit2 (release number or SHA1)

8535fdb

Operating system(s) tested

Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions