mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-15 02:40:38 +00:00
find: Ensure the terminating ;
is present when using -exec
The program now terminates with an error if the command passed to `-exec` is not terminated with a semicolon. This commit also ensures that the argument containing the terminating semicolon must be 1 byte long. Previously, any argument whose first byte was a semicolon was treated as a valid terminator.
This commit is contained in:
parent
8f8354d9a0
commit
2c0f6d8c7b
Notes:
sideshowbarker
2024-07-17 03:35:16 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/2c0f6d8c7b Pull-request: https://github.com/SerenityOS/serenity/pull/21029
1 changed files with 8 additions and 1 deletions
|
@ -808,12 +808,19 @@ static OwnPtr<Command> parse_simple_command(Vector<char*>& args)
|
|||
fatal_error("{}: requires additional arguments", arg);
|
||||
g_have_seen_action_command = true;
|
||||
Vector<char*> command_argv;
|
||||
bool terminator_found = false;
|
||||
while (!args.is_empty()) {
|
||||
char* next = args.take_first();
|
||||
if (next[0] == ';')
|
||||
if (next[0] == ';' && next[1] == '\0') {
|
||||
terminator_found = true;
|
||||
break;
|
||||
}
|
||||
command_argv.append(next);
|
||||
}
|
||||
|
||||
if (!terminator_found)
|
||||
fatal_error("{}: Terminating ';' not found", arg);
|
||||
|
||||
auto await_confirmation = (arg == "-ok") ? ExecCommand::AwaitConfirmation::Yes : ExecCommand::AwaitConfirmation::No;
|
||||
return make<ExecCommand>(move(command_argv), await_confirmation);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue