diff options
author | Ron Yorston <rmy@pobox.com> | 2024-04-21 08:20:38 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-04-21 08:20:38 +0100 |
commit | 90c5352a9746ee76d6219528e00ef5ef39d9dee4 (patch) | |
tree | 0c3a9f7187a7c20de1b87b72c306a8374cb35134 | |
parent | 356bfacef7da39052d404e2db166996cf7b74d4d (diff) | |
download | busybox-w32-90c5352a9746ee76d6219528e00ef5ef39d9dee4.tar.gz busybox-w32-90c5352a9746ee76d6219528e00ef5ef39d9dee4.tar.bz2 busybox-w32-90c5352a9746ee76d6219528e00ef5ef39d9dee4.zip |
make: change how macros are read from the environment
Originally there was no validation of macro names imported from
the environment. However, process_macros() failed to account for
the additional flag bit at this level. Thus, for example, SHELL
was imported when it shouldn't have been.
The problem the lack of validation was supposed to address was
that of environment variables with invalid names, which the user
may not have control over, causing a fatal error.
As an alternative, silently ignore variables with invalid names
on import from the environment.
-rw-r--r-- | miscutils/make.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 970919ddc..cc35d89eb 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -742,7 +742,10 @@ setmacro(const char *name, const char *val, int level) | |||
742 | // If not defined, allocate space for new | 742 | // If not defined, allocate space for new |
743 | unsigned int bucket; | 743 | unsigned int bucket; |
744 | 744 | ||
745 | if (!valid && !is_valid_macro(name)) | 745 | if (!valid && !is_valid_macro(name)) { |
746 | // Silently drop invalid names from the environment | ||
747 | if (level == 3) | ||
748 | return; | ||
746 | #if ENABLE_FEATURE_MAKE_POSIX | 749 | #if ENABLE_FEATURE_MAKE_POSIX |
747 | error("invalid macro name '%s'%s", name, | 750 | error("invalid macro name '%s'%s", name, |
748 | potentially_valid_macro(name) ? | 751 | potentially_valid_macro(name) ? |
@@ -750,6 +753,7 @@ setmacro(const char *name, const char *val, int level) | |||
750 | #else | 753 | #else |
751 | error("invalid macro name '%s'", name); | 754 | error("invalid macro name '%s'", name); |
752 | #endif | 755 | #endif |
756 | } | ||
753 | 757 | ||
754 | bucket = getbucket(name); | 758 | bucket = getbucket(name); |
755 | mp = xzalloc(sizeof(struct macro)); | 759 | mp = xzalloc(sizeof(struct macro)); |
@@ -2929,7 +2933,7 @@ int make_main(int argc UNUSED_PARAM, char **argv) | |||
2929 | } | 2933 | } |
2930 | 2934 | ||
2931 | // Process macro definitions from the environment | 2935 | // Process macro definitions from the environment |
2932 | process_macros(environ, 3 | M_VALID); | 2936 | process_macros(environ, 3); |
2933 | 2937 | ||
2934 | // Update MAKEFLAGS and environment | 2938 | // Update MAKEFLAGS and environment |
2935 | update_makeflags(); | 2939 | update_makeflags(); |