[SV 59230] Ensure environment variables are exportable

When checking for invalid environment variable names we searched the
entire name string instead of just the first LENGTH chars; this could
cause us to incorrectly decide the variable was not exportable.

Dmitry Goncharov <dgoncharov@users.sf.net> found this bug and
provided a test case and sample fix: I used the test but chose a
slightly different fix.

* src/variable.c (define_variable_in_set): check the variable name
not the input string.
* tests/scripts/features/targetvars: Ensure environment variable
values are exported.
This commit is contained in:
Paul Smith
2020-11-27 16:56:22 -05:00
parent 0e020bbc24
commit 19ae6fe72a
2 changed files with 12 additions and 0 deletions

View File

@@ -281,6 +281,16 @@ all: ; $sname
unlink("sd/$sname");
rmdir ('sd');
# SV 59230: Conditional (non-)assignment of target-specific variables should
# preserve export settings.
$ENV{hello} = 'moon';
run_make_test(q!
all:; @echo hello=$$hello
dummy: hello?=world
!,
'', 'hello=moon');
# TEST #19: Test define/endef variables as target-specific vars
# run_make_test('