[git commit] hush: fix a possible bug

Denys Vlasenko vda.linux at googlemail.com
Thu Jul 21 12:42:13 UTC 2016


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

Not sure this was actually a triggerable bug, but the code looked flaky.

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/hush.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/shell/hush.c b/shell/hush.c
index eabe83a..ab192e2 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9153,9 +9153,11 @@ static int FAST_FUNC builtin_break(char **argv)
 	unsigned depth;
 	if (G.depth_of_loop == 0) {
 		bb_error_msg("%s: only meaningful in a loop", argv[0]);
+		/* if we came from builtin_continue(), need to undo "= 1" */
+		G.flag_break_continue = 0;
 		return EXIT_SUCCESS; /* bash compat */
 	}
-	G.flag_break_continue++; /* BC_BREAK = 1 */
+	G.flag_break_continue++; /* BC_BREAK = 1, or BC_CONTINUE = 2 */
 
 	G.depth_break_continue = depth = parse_numeric_argv1(argv, 1, 1);
 	if (depth == UINT_MAX)


More information about the busybox-cvs mailing list