diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2022-11-11 14:59:54 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2022-11-11 14:59:54 -0500 |
commit | 712b13756a09014ef730c8f9b96da4dc2f09b762 (patch) | |
tree | 79117c04624d79ae4d4d007f95c228377c046fb5 | |
parent | 5ce883daaafc69f83b01dac5db0647e9662a6e87 (diff) | |
download | bfs-712b13756a09014ef730c8f9b96da4dc2f09b762.tar.xz |
exec: Fix index overflow parsing -exec +
-rw-r--r-- | src/exec.c | 2 | ||||
-rw-r--r-- | tests/posix/exec_plus_nothing.sh | 2 | ||||
-rw-r--r-- | tests/posix/ok_plus_nothing.sh | 2 |
3 files changed, 5 insertions, 1 deletions
@@ -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; diff --git a/tests/posix/exec_plus_nothing.sh b/tests/posix/exec_plus_nothing.sh new file mode 100644 index 0000000..ef01968 --- /dev/null +++ b/tests/posix/exec_plus_nothing.sh @@ -0,0 +1,2 @@ +# Regression test: don't look OOB for {} + +fail invoke_bfs basic -exec + diff --git a/tests/posix/ok_plus_nothing.sh b/tests/posix/ok_plus_nothing.sh new file mode 100644 index 0000000..7cb7de5 --- /dev/null +++ b/tests/posix/ok_plus_nothing.sh @@ -0,0 +1,2 @@ +# Regression test: don't look OOB for {} + +fail invoke_bfs basic -ok + |