make(1): add test for intentional hash collision for variable names
Hash collisions may slow down make in certain special situations. There is no point though in maliciously triggering such a situation since anyone who can inject values into makefiles can easily run shell commands using the :!cmd! modifier or similar mechanisms. Crafting variable names just to slow down make is thus not an attack vector.
This commit is contained in:
parent
c4c51006fe
commit
6544b03ea1
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.135 2020/09/05 06:36:40 rillig Exp $
|
||||
# $NetBSD: Makefile,v 1.136 2020/09/05 12:59:07 rillig Exp $
|
||||
#
|
||||
# Unit tests for make(1)
|
||||
#
|
||||
@ -393,6 +393,7 @@ POSTPROC.deptgt-suffixes= \
|
||||
${TOOL_SED} -n -e '/^\#\*\*\* Suffixes/,/^\#\*/p'
|
||||
POSTPROC.vardebug= ${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
|
||||
POSTPROC.varmod-match-escape= ${TOOL_SED} -n -e '/^Pattern/p'
|
||||
POSTPROC.varname= ${TOOL_SED} -n -e '/^MAGIC/p' -e '/^ORDER_/p'
|
||||
POSTPROC.varname-dot-shell= \
|
||||
awk '/\.SHELL/ || /^ParseReadLine/'
|
||||
POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
|
||||
|
@ -1,8 +1,43 @@
|
||||
# $NetBSD: varname.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
|
||||
# $NetBSD: varname.mk,v 1.3 2020/09/05 12:59:07 rillig Exp $
|
||||
#
|
||||
# Tests for special variables, such as .MAKE or .PARSEDIR.
|
||||
|
||||
# TODO: Implementation
|
||||
# These following MAGIC variables have the same hash code, at least with
|
||||
# the default hashing algorithm, which is the same as in Java. The order
|
||||
# in which these variables are defined determines the order in which they
|
||||
# appear in the Hash_Table. New entries are prepended to the bucket lists,
|
||||
# therefore this test numbers the values in descending order.
|
||||
|
||||
.if defined(ORDER_01)
|
||||
|
||||
MAGIC0a0a0a= 8
|
||||
MAGIC0a0a1B= 7
|
||||
MAGIC0a1B0a= 6
|
||||
MAGIC0a1B1B= 5
|
||||
MAGIC1B0a0a= 4
|
||||
MAGIC1B0a1B= 3
|
||||
MAGIC1B1B0a= 2
|
||||
MAGIC1B1B1B= 1
|
||||
|
||||
all: # nothing
|
||||
|
||||
.elif defined(ORDER_10)
|
||||
|
||||
MAGIC1B1B1B= 8
|
||||
MAGIC1B1B0a= 7
|
||||
MAGIC1B0a1B= 6
|
||||
MAGIC1B0a0a= 5
|
||||
MAGIC0a1B1B= 4
|
||||
MAGIC0a1B0a= 3
|
||||
MAGIC0a0a1B= 2
|
||||
MAGIC0a0a0a= 1
|
||||
|
||||
all: # nothing
|
||||
|
||||
.else
|
||||
|
||||
all:
|
||||
@:;
|
||||
@${.MAKE} -f ${MAKEFILE} -dg1 ORDER_01=yes
|
||||
@${.MAKE} -f ${MAKEFILE} -dg1 ORDER_10=yes
|
||||
|
||||
.endif
|
||||
|
Loading…
Reference in New Issue
Block a user