[git commit] ash: parser: Fix incorrect eating of backslash newlines

Denys Vlasenko vda.linux at googlemail.com
Sun Feb 16 18:14:45 UTC 2020


commit: https://git.busybox.net/busybox/commit/?id=f7eea8c235dea6699a21c7b26c218e6c0dc1bf95
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Keeping up with upstream (in our case, 'before patch' code is not buggy).
Upstream commit:

    Date: Fri, 11 May 2018 23:41:25 +0800
    parser: Fix incorrect eating of backslash newlines

    With the introduction of synstack->syntax, a number of references
    to the syntax variable was missed during the conversion.  This
    causes backslash newlines to be incorrectly removed in single
    quote context.

    This patch also combines these calls into a new helper function
    pgetc_top.

    Fixes: ab1cecb40478 ("parser: Add syntax stack for recursive...")
    Reported-by: Leah Neukirchen <leah at vuxu.org>
    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index c177ac038..a300061a2 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -10829,6 +10829,12 @@ struct synstack {
 	struct synstack *next;
 };
 
+static int
+pgetc_top(struct synstack *stack)
+{
+	return stack->syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+}
+
 static void
 synstack_push(struct synstack **stack, struct synstack *next, int syntax)
 {
@@ -12194,7 +12200,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
 			}
 			USTPUTC(c, out);
 			nlprompt();
-			c = synstack->syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+			c = pgetc_top(synstack);
 			goto loop;              /* continue outer loop */
 		case CWORD:
 			USTPUTC(c, out);
@@ -12345,7 +12351,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
 			IF_ASH_ALIAS(if (c != PEOA))
 				USTPUTC(c, out);
 		}
-		c = synstack->syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+		c = pgetc_top(synstack);
 	} /* for (;;) */
  endword:
 


More information about the busybox-cvs mailing list