Skip to content

Commit 474bf0d

Browse files
committed
Make the script more robust, and don't require ex
1 parent 4e3b77d commit 474bf0d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

gix-worktree/tests/fixtures/make_traverse_dotdot_trees.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,35 @@
33
set -eu
44

55
repo="$1"
6+
target_bin='.cargo/bin'
7+
68
git init -- "$repo"
79
cd -- "$repo"
810

9-
cat >ls.tmp <<'EOF'
11+
cat >payload <<'EOF'
1012
#!/bin/sh
1113
printf 'Vulnerable!\n'
1214
date >~/vulnerable
1315
exec /bin/ls "$@"
1416
EOF
15-
chmod +x ls.tmp
17+
chmod +x payload
1618

1719
upward='..'
1820
for subdir in .a .b .c .d .e .f .g .h .i .j; do
19-
upward="..@$upward"
20-
cp -- ls.tmp "$subdir@$upward@.cargo@bin@ls"
21+
upward="../$upward"
22+
target="$subdir/$upward/$target_bin/ls"
23+
standin="$(printf '%s' "$target" | tr / @)"
24+
2125
mkdir -- "$subdir"
2226
touch -- "$subdir/.keep"
27+
cp -- payload "$standin"
28+
git add -- "$subdir/.keep" "$standin"
29+
30+
standin_pattern="$(printf '%s' "$standin" | sed 's|\.|\\\.|g')"
31+
cp .git/index old_index
32+
sed "s|$standin_pattern|$target|g" old_index >.git/index
2333
done
2434

25-
rm ls.tmp
26-
git add .
27-
ex -s -c '%s/@\.\./\/../g' -c '%s/@\.cargo@bin@ls/\/.cargo\/bin\/ls/g' -c 'x' .git/index
2835
git commit -m 'Initial commit'
36+
rm payload old_index
2937
git show --stat

0 commit comments

Comments
 (0)