Skip to content

Commit a30959e

Browse files
committed
Use absolute paths for processing and display.
This resolves a bug where a directory named like “-h” would result in ‘find’ erroring out about unknown predicates, but also had potential security implications with constructing directory names to make ‘find’ run any command desired.
1 parent f23d101 commit a30959e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

reflac

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,21 @@ fi
115115

116116
for dir do
117117
if [ $RECURSIVE -eq 1 ] && [ $NOACTION -eq 1 ]; then
118-
find "$dir" -type d -exec "$SELF" -nv {} \;
118+
find "$(readlink -f -- "$dir")" -type d -execdir "$SELF" -nv {} \;
119119
elif [ $RECURSIVE -eq 1 ]; then
120120
if [ $VERBOSE -eq 1 ]; then
121-
find "$dir" -type d -exec "$SELF" -v -"$FLAC_LEVEL" {} \;
121+
find "$(readlink -f -- "$dir")" -type d \
122+
-execdir "$SELF" -v -"$FLAC_LEVEL" {} \;
122123
elif [ $VERBOSE -ge 2 ]; then
123-
find "$dir" -type d -exec "$SELF" -vv -"$FLAC_LEVEL" {} \;
124+
find "$(readlink -f -- "$dir")" -type d \
125+
-execdir "$SELF" -vv -"$FLAC_LEVEL" {} \;
124126
else
125-
find "$dir" -type d -exec "$SELF" -"$FLAC_LEVEL" {} \;
127+
find "$(readlink -f -- "$dir")" -type d \
128+
-execdir "$SELF" -"$FLAC_LEVEL" {} \;
126129
fi
127130
else
128131
cd -- "$dir"
129-
if [ $VERBOSE -gt 0 ]; then echo "$dir"; fi
132+
if [ $VERBOSE -gt 0 ]; then echo "$(readlink -f .)"; fi
130133
if [ ! -z "$(ls -- *.flac 2>/dev/null)" ]; then
131134
recompress
132135
fi

0 commit comments

Comments
 (0)