Skip to content

Commit

Permalink
exec: Fix index overflow parsing -exec +
Browse files Browse the repository at this point in the history
  • Loading branch information
tavianator committed Nov 11, 2022
1 parent 5ce883d commit 712b137
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ struct bfs_exec *bfs_exec_parse(const struct bfs_ctx *ctx, char **argv, enum bfs
goto fail;
} else if (strcmp(arg, ";") == 0) {
break;
} else if (strcmp(arg, "+") == 0) {
} else if (execbuf->tmpl_argc > 0 && strcmp(arg, "+") == 0) {
const char *prev = execbuf->tmpl_argv[execbuf->tmpl_argc - 1];
if (!(execbuf->flags & BFS_EXEC_CONFIRM) && strcmp(prev, "{}") == 0) {
execbuf->flags |= BFS_EXEC_MULTI;
Expand Down
2 changes: 2 additions & 0 deletions tests/posix/exec_plus_nothing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Regression test: don't look OOB for {} +
fail invoke_bfs basic -exec +
2 changes: 2 additions & 0 deletions tests/posix/ok_plus_nothing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Regression test: don't look OOB for {} +
fail invoke_bfs basic -ok +

0 comments on commit 712b137

Please sign in to comment.