Skip to content

Commit 27d3201

Browse files
awilfoxRafaelGSS
authored andcommitted
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c6c0947 commit 27d3201

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/env.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ std::string GetExecPath(const std::vector<std::string>& argv) {
619619
std::string exec_path;
620620
if (uv_exepath(exec_path_buf, &exec_path_len) == 0) {
621621
exec_path = std::string(exec_path_buf, exec_path_len);
622-
} else {
622+
} else if (argv.size() > 0) {
623623
exec_path = argv[0];
624624
}
625625

0 commit comments

Comments
 (0)