summaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2024-04-17 11:38:18 +0200
committerJohannes Schindelin <johannes.schindelin@gmx.de>2024-04-19 12:38:42 +0200
commitf5b2af06f55c0f21ae0199be5fe120f2cccd698b (patch)
tree8a247278428ea30cef8baeb0d98e425f3fb51028 /dir.c
parentMerge branch 'jk/redact-h2h3-headers-fix' into maint-2.41 (diff)
parentGit 2.40.2 (diff)
downloadgit-f5b2af06f55c0f21ae0199be5fe120f2cccd698b.tar.xz
git-f5b2af06f55c0f21ae0199be5fe120f2cccd698b.zip
Sync with 2.40.2
* maint-2.40: (39 commits) Git 2.40.2 Git 2.39.4 fsck: warn about symlink pointing inside a gitdir core.hooksPath: add some protection while cloning init.templateDir: consider this config setting protected clone: prevent hooks from running during a clone Add a helper function to compare file contents init: refactor the template directory discovery into its own function find_hook(): refactor the `STRIP_EXTENSION` logic clone: when symbolic links collide with directories, keep the latter entry: report more colliding paths t5510: verify that D/F confusion cannot lead to an RCE submodule: require the submodule path to contain directories only clone_submodule: avoid using `access()` on directories submodules: submodule paths must not contain symlinks clone: prevent clashing git dirs when cloning submodule in parallel t7423: add tests for symlinked submodule directories has_dir_name(): do not get confused by characters < '/' docs: document security issues around untrusted .git dirs upload-pack: disable lazy-fetching by default ...
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index a7469df3ac..713282de71 100644
--- a/dir.c
+++ b/dir.c
@@ -99,6 +99,18 @@ int fspathncmp(const char *a, const char *b, size_t count)
return ignore_case ? strncasecmp(a, b, count) : strncmp(a, b, count);
}
+int paths_collide(const char *a, const char *b)
+{
+ size_t len_a = strlen(a), len_b = strlen(b);
+
+ if (len_a == len_b)
+ return fspatheq(a, b);
+
+ if (len_a < len_b)
+ return is_dir_sep(b[len_a]) && !fspathncmp(a, b, len_a);
+ return is_dir_sep(a[len_b]) && !fspathncmp(a, b, len_b);
+}
+
unsigned int fspathhash(const char *str)
{
return ignore_case ? strihash(str) : strhash(str);