diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2021-06-06 01:13:25 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-08 11:30:58 +0200 |
commit | d6a3f1fcd7e5458cdf0cc777e159ebadebbd2cd1 (patch) | |
tree | 282b623ce4181c3ef3417eea5fda85a99ad5fd64 /Kernel/Syscalls | |
parent | 250f8eccf31313ab7f435f9bf119d90564d95eb6 (diff) | |
download | serenity-d6a3f1fcd7e5458cdf0cc777e159ebadebbd2cd1.zip |
Kernel: Simplify `execve` shebang argument handling
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/execve.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index ba6b0f72cc..8c4a9179fa 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -846,14 +846,11 @@ KResult Process::exec(String path, Vector<String> arguments, Vector<String> envi // 1) #! interpreted file auto shebang_result = find_shebang_interpreter_for_executable(first_page, nread_or_error.value()); if (!shebang_result.is_error()) { - Vector<String> new_arguments(shebang_result.value()); - - new_arguments.append(path); - - arguments.remove(0); - new_arguments.append(move(arguments)); - - return exec(shebang_result.value().first(), move(new_arguments), move(environment), ++recursion_depth); + auto shebang_words = shebang_result.release_value(); + auto shebang_path = shebang_words.first(); + if (!arguments.try_prepend(move(shebang_words))) + return ENOMEM; + return exec(shebang_path, move(arguments), move(environment), ++recursion_depth); } // #2) ELF32 for i386 |