clone: when symbolic links collide with directories, keep the latter
commit31572dc420afee36db8fbbbe060dd78c9a48778c
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 28 Mar 2024 09:55:07 +0000 (28 10:55 +0100)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 17 Apr 2024 20:30:08 +0000 (17 22:30 +0200)
tree085a836f627a0d82920d65e95ddd199eab8dbfa5
parent850c3a220e7a0b1bf740fba9ac8f3f2b0486a1af
clone: when symbolic links collide with directories, keep the latter

When recursively cloning a repository with submodules, we must ensure
that the submodules paths do not suddenly contain symbolic links that
would let Git write into unintended locations. We just plugged that
vulnerability, but let's add some more defense-in-depth.

Since we can only keep one item on disk if multiple index entries' paths
collide, we may just as well avoid keeping a symbolic link (because that
would allow attack vectors where Git follows those links by mistake).

Technically, we handle more situations than cloning submodules into
paths that were (partially) replaced by symbolic links. This provides
defense-in-depth in case someone finds a case-folding confusion
vulnerability in the future that does not even involve submodules.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
entry.c
t/t5601-clone.sh
t/t7406-submodule-update.sh