mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
UE: Don't look up binaries in PATH when the user specified a full path
When the user specifies a path such as ./test we'd incorrectly look for the binary in the PATH environment variable and end up executing an incorrect binary (e.g. /bin/test). We should only look up binaries in PATH if the user-specified path does not contain a slash.
This commit is contained in:
parent
26e711f953
commit
ee6600ea24
Notes:
sideshowbarker
2024-07-18 17:56:04 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/ee6600ea240 Pull-request: https://github.com/SerenityOS/serenity/pull/7211 Reviewed-by: https://github.com/awesomekling
1 changed files with 7 additions and 6 deletions
|
@ -26,13 +26,14 @@ int main(int argc, char** argv, char** env)
|
|||
parser.add_positional_argument(arguments, "Command to emulate", "command");
|
||||
parser.parse(argc, argv);
|
||||
|
||||
auto executable_path = Core::find_executable_in_path(arguments[0]);
|
||||
if (executable_path.is_empty()) {
|
||||
String executable_path;
|
||||
if (arguments[0].contains("/"sv))
|
||||
executable_path = Core::File::real_path_for(arguments[0]);
|
||||
if (executable_path.is_empty()) {
|
||||
reportln("Cannot find executable for '{}'.", executable_path);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
executable_path = Core::find_executable_in_path(arguments[0]);
|
||||
if (executable_path.is_empty()) {
|
||||
reportln("Cannot find executable for '{}'.", arguments[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Vector<String> environment;
|
||||
|
|
Loading…
Reference in a new issue