diff options
author | Ron Yorston <rmy@pobox.com> | 2015-10-29 16:44:56 +0000 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-29 20:45:36 +0100 |
commit | 713f07d906d9171953be0c12e2369869855b6ca6 (patch) | |
tree | 925c1248b01de9ad188f9ebf7e48fac3b3838fe9 /shell | |
parent | 7b14ede049d467e1a6da46ef69b917645e94a6b9 (diff) | |
download | busybox-w32-713f07d906d9171953be0c12e2369869855b6ca6.tar.gz busybox-w32-713f07d906d9171953be0c12e2369869855b6ca6.tar.bz2 busybox-w32-713f07d906d9171953be0c12e2369869855b6ca6.zip |
ash: fix error during recursive processing of here document
Save the value of the checkkwd flag to prevent it being clobbered
during recursion.
Based on commit ec2c84d from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu.
function old new delta
readtoken 190 203 +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0) Total: 13 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 5 | ||||
-rw-r--r-- | shell/ash_test/ash-heredoc/heredoc3.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-heredoc/heredoc3.tests | 9 |
3 files changed, 13 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index 0d7cac0b5..384c7b9e4 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -11899,6 +11899,7 @@ static int | |||
11899 | readtoken(void) | 11899 | readtoken(void) |
11900 | { | 11900 | { |
11901 | int t; | 11901 | int t; |
11902 | int kwd = checkkwd; | ||
11902 | #if DEBUG | 11903 | #if DEBUG |
11903 | smallint alreadyseen = tokpushback; | 11904 | smallint alreadyseen = tokpushback; |
11904 | #endif | 11905 | #endif |
@@ -11912,7 +11913,7 @@ readtoken(void) | |||
11912 | /* | 11913 | /* |
11913 | * eat newlines | 11914 | * eat newlines |
11914 | */ | 11915 | */ |
11915 | if (checkkwd & CHKNL) { | 11916 | if (kwd & CHKNL) { |
11916 | while (t == TNL) { | 11917 | while (t == TNL) { |
11917 | parseheredoc(); | 11918 | parseheredoc(); |
11918 | t = xxreadtoken(); | 11919 | t = xxreadtoken(); |
@@ -11926,7 +11927,7 @@ readtoken(void) | |||
11926 | /* | 11927 | /* |
11927 | * check for keywords | 11928 | * check for keywords |
11928 | */ | 11929 | */ |
11929 | if (checkkwd & CHKKWD) { | 11930 | if (kwd & CHKKWD) { |
11930 | const char *const *pp; | 11931 | const char *const *pp; |
11931 | 11932 | ||
11932 | pp = findkwd(wordtext); | 11933 | pp = findkwd(wordtext); |
diff --git a/shell/ash_test/ash-heredoc/heredoc3.right b/shell/ash_test/ash-heredoc/heredoc3.right new file mode 100644 index 000000000..ce0136250 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc3.right | |||
@@ -0,0 +1 @@ | |||
hello | |||
diff --git a/shell/ash_test/ash-heredoc/heredoc3.tests b/shell/ash_test/ash-heredoc/heredoc3.tests new file mode 100755 index 000000000..96c227cc1 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc3.tests | |||
@@ -0,0 +1,9 @@ | |||
1 | echo hello >greeting | ||
2 | cat <<EOF && | ||
3 | $(cat greeting) | ||
4 | EOF | ||
5 | { | ||
6 | echo $? | ||
7 | cat greeting | ||
8 | } >/dev/null | ||
9 | rm greeting | ||