From de5dc219d8f719cd1126f4dd8294642e4c24d6ea Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 23 Jan 2020 13:21:24 -0500 Subject: [PATCH] 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. --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 9c7e338..ae52ba5 100644 --- a/Makefile +++ b/Makefile @@ -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 "$$@" .' ':' {} + )