From: millert Date: Mon, 5 Jul 2021 13:41:46 +0000 (+0000) Subject: Do not permit an empty list between "while" and "do". X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4685f2425243bee1be89977409e0daafa2db3d6d;p=openbsd Do not permit an empty list between "while" and "do". This avoids a cpu loop for "while do done" and is consistent with the behavior of AT&T ksh and most other shells. OK jca@ halex@ --- diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c index 4d845d9eca5..5de47704dc6 100644 --- a/bin/ksh/syn.c +++ b/bin/ksh/syn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syn.c,v 1.39 2018/04/24 08:25:16 kn Exp $ */ +/* $OpenBSD: syn.c,v 1.40 2021/07/05 13:41:46 millert Exp $ */ /* * shell parser (C version) @@ -331,6 +331,8 @@ get_command(int cf) nesting_push(&old_nesting, c); t = newtp((c == WHILE) ? TWHILE : TUNTIL); t->left = c_list(true); + if (t->left == NULL) + syntaxerr(NULL); t->right = dogroup(); nesting_pop(&old_nesting); break;