diff options
author | Ron Yorston <rmy@pobox.com> | 2024-06-10 12:46:50 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-06-10 12:46:50 +0100 |
commit | a518a4f6023582744fa271ec279375dd3d51a4d4 (patch) | |
tree | 3ccbaa9fb0d537df01e3f4b6ec13206744d7909e | |
parent | 997961d8a9a2c67e06508ac5f3733edb3ad6ebc7 (diff) | |
download | busybox-w32-a518a4f6023582744fa271ec279375dd3d51a4d4.tar.gz busybox-w32-a518a4f6023582744fa271ec279375dd3d51a4d4.tar.bz2 busybox-w32-a518a4f6023582744fa271ec279375dd3d51a4d4.zip |
make: limit changes to pragmas
The special target .PRAGMA could be used to set or reset pragmas.
Doing anything other than setting pragmas very early in execution
is likely to be problematic.
Limit the abilities of .PRAGMA:
- Specifying .PRAGMA with no prerequisites now does nothing:
pragmas are not reset.
- The posix_2017 and posix_202x pragmas can only be used to change
the enforced POSIX level from the default. Any further attempt
to change POSIX level results in a warning.
Adds 16-32 bytes.
-rw-r--r-- | miscutils/make.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 7d2196139..c9f8cc506 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -656,7 +656,10 @@ set_pragma(const char *name) | |||
656 | if (idx >= BIT_POSIX_2017) { | 656 | if (idx >= BIT_POSIX_2017) { |
657 | // POSIX level is stored in a separate variable. | 657 | // POSIX level is stored in a separate variable. |
658 | // No bits in 'pragma' are used. | 658 | // No bits in 'pragma' are used. |
659 | posix_level = idx - BIT_POSIX_2017; | 659 | if (posix_level == DEFAULT_POSIX_LEVEL) |
660 | posix_level = idx - BIT_POSIX_2017; | ||
661 | else if (posix_level != idx - BIT_POSIX_2017) | ||
662 | warning("unable to change POSIX level"); | ||
660 | } else { | 663 | } else { |
661 | pragma |= 1 << idx; | 664 | pragma |= 1 << idx; |
662 | } | 665 | } |
@@ -693,10 +696,6 @@ addrule(struct name *np, struct depend *dp, struct cmd *cp, int flag) | |||
693 | if ((np->n_flag & N_SPECIAL) && !dp && !cp) { | 696 | if ((np->n_flag & N_SPECIAL) && !dp && !cp) { |
694 | if (strcmp(np->n_name, ".PHONY") == 0) | 697 | if (strcmp(np->n_name, ".PHONY") == 0) |
695 | return; | 698 | return; |
696 | #if ENABLE_FEATURE_MAKE_POSIX | ||
697 | if (strcmp(np->n_name, ".PRAGMA") == 0) | ||
698 | pragma = 0; | ||
699 | #endif | ||
700 | freerules(np->n_rule); | 699 | freerules(np->n_rule); |
701 | np->n_rule = NULL; | 700 | np->n_rule = NULL; |
702 | return; | 701 | return; |