summaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
authorRon Yorston2018-11-25 11:46:39 +0000
committerDenys Vlasenko2018-11-27 10:47:06 +0100
commit2d217799e8f23514ad3be6a951aa928c265bc6a4 (patch)
treee9ecd255767ec33df1bfe24c5f551d14de07063c /applets
parent7b42f8fc76d78fe9c6b0cbe15e1425f2fd9fb5e8 (diff)
downloadbusybox-2d217799e8f23514ad3be6a951aa928c265bc6a4.zip
busybox-2d217799e8f23514ad3be6a951aa928c265bc6a4.tar.gz
build system: prevent duplicate applet names
The embedded script feature makes it easier to create applets with duplicate names. Currently in such cases the build succeeds but the resulting executable doesn't work as the developer intended. Catch duplicate names when the applet tables are being generated and make the build fail. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'applets')
-rw-r--r--applets/applet_tables.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/applets/applet_tables.c b/applets/applet_tables.c
index e3d10c8..ce20374 100644
--- a/applets/applet_tables.c
+++ b/applets/applet_tables.c
@@ -84,7 +84,15 @@ int main(int argc, char **argv)
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
- if (!argv[1])
+ for (i = j = 0; i < NUM_APPLETS-1; ++i) {
+ if (cmp_name(applets+i, applets+i+1) == 0) {
+ fprintf(stderr, "%s: duplicate applet name '%s'\n", argv[0],
+ applets[i].name);
+ j = 1;
+ }
+ }
+
+ if (j != 0 || !argv[1])
return 1;
snprintf(tmp1, PATH_MAX, "%s.%u.new", argv[1], (int) getpid());
i = open(tmp1, O_WRONLY | O_TRUNC | O_CREAT, 0666);