diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-11-14 20:36:09 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-11-14 20:42:10 -0500 |
commit | 90c7fba2d3d1081fb7a4d6a3d9a7e3c2132f33f6 (patch) | |
tree | 234a467f2a8936472107c770d45099da105ff73e /exec.c | |
parent | 14065fe78c133bc49e46557a8cfdec7ed6b618bc (diff) | |
download | bfs-90c7fba2d3d1081fb7a4d6a3d9a7e3c2132f33f6.tar.xz |
exec: Reject -exec \; without a command
Prior to this, we'd fork and then segfault on every file as NULL was
passed to execvpe(). Found while looking through old FreeBSD find bugs:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=36521
bfs still supports the (dubious, possibly unintentional?) GNU find
extension to POSIX that allows
$ bfs -exec {} \;
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -160,6 +160,11 @@ struct bfs_exec *parse_bfs_exec(char **argv, enum bfs_exec_flags flags, const st execbuf->tmpl_argv = argv + 1; execbuf->tmpl_argc = i - 1; + if (execbuf->tmpl_argc == 0) { + cfprintf(cerr, "%{er}error: %s: Missing command.%{rs}\n", argv[0]); + goto fail; + } + execbuf->argv_cap = execbuf->tmpl_argc + 1; execbuf->argv = malloc(execbuf->argv_cap*sizeof(*execbuf->argv)); if (!execbuf->argv) { |