Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
src: check size of args before using for exec_path
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 juanarbol committed Jan 31, 2023
1 parent 7a97f3f commit 574afac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/env.cc
Expand Up @@ -618,7 +618,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 574afac

Please sign in to comment.