diff options
author | Ron Yorston <rmy@pobox.com> | 2023-10-24 11:41:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-10-24 11:41:12 +0100 |
commit | e0fd5d3c112df92b3d104b519ed09770f24d2ecf (patch) | |
tree | 4080cb0abcaea8ee0c3bacd0287f0112878278b6 | |
parent | 035b860aa381a2d9f21f075240d317a4cb9c8c64 (diff) | |
download | busybox-w32-e0fd5d3c112df92b3d104b519ed09770f24d2ecf.tar.gz busybox-w32-e0fd5d3c112df92b3d104b519ed09770f24d2ecf.tar.bz2 busybox-w32-e0fd5d3c112df92b3d104b519ed09770f24d2ecf.zip |
make: stricter checks for c:/path filenames
When checking target names or looking for a target rule be more
strict about the form of Windows paths allowed.
Alter the error message when neither a target rule or macro
assignment has been detected.
Adds 88-96 bytes.
-rw-r--r-- | miscutils/make.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 695f77fa6..22d6abeea 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -438,6 +438,13 @@ check_name(const char *name) | |||
438 | { | 438 | { |
439 | const char *s; | 439 | const char *s; |
440 | 440 | ||
441 | #if ENABLE_PLATFORM_MINGW32 | ||
442 | if (!posix || (pragma & P_WINDOWS)) { | ||
443 | if (isalpha(name[0]) && name[1] == ':' && name[2] == '/') { | ||
444 | name += 3; | ||
445 | } | ||
446 | } | ||
447 | #endif | ||
441 | if (!posix) { | 448 | if (!posix) { |
442 | for (s = name; *s; ++s) { | 449 | for (s = name; *s; ++s) { |
443 | if (*s == '=') | 450 | if (*s == '=') |
@@ -447,10 +454,6 @@ check_name(const char *name) | |||
447 | } | 454 | } |
448 | 455 | ||
449 | for (s = name; *s; ++s) { | 456 | for (s = name; *s; ++s) { |
450 | #if ENABLE_PLATFORM_MINGW32 | ||
451 | if ((pragma & P_WINDOWS) && *s == ':') | ||
452 | continue; | ||
453 | #endif | ||
454 | if ((pragma & P_TARGET_NAME) || !POSIX_2017 ? | 457 | if ((pragma & P_TARGET_NAME) || !POSIX_2017 ? |
455 | !(isfname(*s) || *s == '/') : !ispname(*s)) | 458 | !(isfname(*s) || *s == '/') : !ispname(*s)) |
456 | return FALSE; | 459 | return FALSE; |
@@ -1175,7 +1178,7 @@ find_colon(char *p) | |||
1175 | for (q = p; (q = strchr(q, ':')); ++q) { | 1178 | for (q = p; (q = strchr(q, ':')); ++q) { |
1176 | if (posix && !(pragma & P_WINDOWS)) | 1179 | if (posix && !(pragma & P_WINDOWS)) |
1177 | break; | 1180 | break; |
1178 | if (q[1] != '/') | 1181 | if (q == p || !isalpha(q[-1]) || q[1] != '/') |
1179 | break; | 1182 | break; |
1180 | } | 1183 | } |
1181 | if (q != NULL) { | 1184 | if (q != NULL) { |
@@ -2123,7 +2126,7 @@ input(FILE *fd, int ilevel) | |||
2123 | setmacro(a, q, level); | 2126 | setmacro(a, q, level); |
2124 | free(newq); | 2127 | free(newq); |
2125 | } else { | 2128 | } else { |
2126 | error("expected macro definition"); | 2129 | error("missing separator"); |
2127 | } | 2130 | } |
2128 | 2131 | ||
2129 | end_loop: | 2132 | end_loop: |