[git commit] ash: only allow local variables in functions
Denys Vlasenko
vda.linux at googlemail.com
Thu Oct 29 19:33:44 UTC 2015
commit: http://git.busybox.net/busybox/commit/?id=ef2386b80abfb22ccb697ddbdd4047aacc395c50
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Ron Yorston <rmy at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
shell/ash.c | 3 +++
shell/ash_test/ash-misc/local2.right | 1 +
shell/ash_test/ash-misc/local2.tests | 1 +
3 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/shell/ash.c b/shell/ash.c
index a2e0618..0d7cac0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8987,6 +8987,9 @@ localcmd(int argc UNUSED_PARAM, char **argv)
{
char *name;
+ if (!funcnest)
+ ash_msg_and_raise_error("not in a function");
+
argv = argptr;
while ((name = *argv++) != NULL) {
mklocal(name);
diff --git a/shell/ash_test/ash-misc/local2.right b/shell/ash_test/ash-misc/local2.right
new file mode 100644
index 0000000..630ef79
--- /dev/null
+++ b/shell/ash_test/ash-misc/local2.right
@@ -0,0 +1 @@
+./local2.tests: local: line 1: not in a function
diff --git a/shell/ash_test/ash-misc/local2.tests b/shell/ash_test/ash-misc/local2.tests
new file mode 100755
index 0000000..8e14037
--- /dev/null
+++ b/shell/ash_test/ash-misc/local2.tests
@@ -0,0 +1 @@
+local x=1
More information about the busybox-cvs
mailing list