add safety in make rules involving rm -rf

error out if there are any slashes in the name that will later be
passed to rm -rf since these are implicit rules and could
theoretically get instantiated in unintended ways.
This commit is contained in:
Rich Felker 2020-01-23 13:21:24 -05:00
parent eb979cc08b
commit de5dc219d8
1 changed files with 4 additions and 0 deletions

View File

@ -100,6 +100,7 @@ musl-git-%:
mv $@.tmp $@
%.orig: $(SOURCES)/%.tar.gz
case "$@" in */*) exit 1 ;; esac
rm -rf $@.tmp
mkdir $@.tmp
( cd $@.tmp && tar zxvf - ) < $<
@ -109,6 +110,7 @@ musl-git-%:
rm -rf $@.tmp
%.orig: $(SOURCES)/%.tar.bz2
case "$@" in */*) exit 1 ;; esac
rm -rf $@.tmp
mkdir $@.tmp
( cd $@.tmp && tar jxvf - ) < $<
@ -118,6 +120,7 @@ musl-git-%:
rm -rf $@.tmp
%.orig: $(SOURCES)/%.tar.xz
case "$@" in */*) exit 1 ;; esac
rm -rf $@.tmp
mkdir $@.tmp
( cd $@.tmp && tar Jxvf - ) < $<
@ -127,6 +130,7 @@ musl-git-%:
rm -rf $@.tmp
%: %.orig | $(SOURCES)/config.sub
case "$@" in */*) exit 1 ;; esac
rm -rf $@.tmp
mkdir $@.tmp
( cd $@.tmp && find ../$< -path '*/*/*' -prune -exec sh -c 'ln -s "$$@" .' ':' {} + )