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
PR-URL: #45902
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
awilfox authored and targos committed Jan 1, 2023
1 parent e6da353 commit 9345d60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/env.cc
Original file line number Diff line number Diff line change
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 9345d60

Please sign in to comment.