Skip to content

Commit

Permalink
src: check size of args before using for exec_path
Browse files Browse the repository at this point in the history
If we are in an artifically created Environment that has no args set,
and uv_exepath returns an error (for instance, if /proc is not mounted
on a Linux system), then we crash with a nullptr deref attempting to
use argv[0].

Fixes: #45901
  • Loading branch information
awilfox committed Dec 18, 2022
1 parent ca2ec90 commit c218f7a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/env.cc
Expand Up @@ -619,7 +619,7 @@ std::string GetExecPath(const std::vector<std::string>& argv) {
std::string exec_path;
if (uv_exepath(exec_path_buf, &exec_path_len) == 0) {
exec_path = std::string(exec_path_buf, exec_path_len);
} else {
} else if (argv.size() > 0) {
exec_path = argv[0];
}

Expand Down

0 comments on commit c218f7a

Please sign in to comment.