summaryrefslogtreecommitdiff
path: root/mk/subst.mk
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-04-18 12:21:10 +0000
committerrillig <rillig@pkgsrc.org>2020-04-18 12:21:10 +0000
commit6d6b143d8f4e92c39f6534f7f0362ab471ac2fe0 (patch)
tree0f04e06261a76dc9d8502a583e380f0564b28493 /mk/subst.mk
parent5883c328090c4b268fee26c1f364d556141f0c85 (diff)
downloadpkgsrc-6d6b143d8f4e92c39f6534f7f0362ab471ac2fe0.tar.gz
mk/subst.mk: avoid undefined behavior in regular expressions
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html says in section 9.3.2 BRE Ordinary Characters that only very few characters may be preceded with a backslash. As a side effect, this change allows parentheses in the variable names listed in SUBST_VARS (even if that will never happen in practice). The reason that the regression test had not replaced VAR.[] before was simply that this variable had not been listed in SUBST_VARS.
Diffstat (limited to 'mk/subst.mk')
-rw-r--r--mk/subst.mk4
1 files changed, 2 insertions, 2 deletions
diff --git a/mk/subst.mk b/mk/subst.mk
index 099a130a0ba..cd9b769748a 100644
--- a/mk/subst.mk
+++ b/mk/subst.mk
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.76 2020/04/18 11:42:34 rillig Exp $
+# $NetBSD: subst.mk,v 1.77 2020/04/18 12:21:10 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@@ -128,7 +128,7 @@ SUBST_FILTER_CMD.${class}?= LC_ALL=C ${SED} ${SUBST_SED.${class}}
SUBST_VARS.${class}?= # none
SUBST_MESSAGE.${class}?= Substituting "${class}" in ${SUBST_FILES.${class}}
. for v in ${SUBST_VARS.${class}}
-SUBST_FILTER_CMD.${class}+= -e s,@${v:C|[^A-Za-z0-9_]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g
+SUBST_FILTER_CMD.${class}+= -e s,@${v:C|[.[\\*^${$}]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g
. endfor
. if ${SUBST_SHOW_DIFF.${class}:U${SUBST_SHOW_DIFF}:tl} == yes
_SUBST_KEEP.${class}?= LC_ALL=C ${DIFF} -u "$$file" "$$tmpfile" || true