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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
awilfox authored and RafaelGSS committed Jan 5, 2023
1 parent c6c0947 commit 27d3201
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 27d3201

Please sign in to comment.