Skip to content

Commit 574afac

Browse files
awilfoxjuanarbol
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 <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 7a97f3f commit 574afac

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
@@ -618,7 +618,7 @@ std::string GetExecPath(const std::vector<std::string>& argv) {
618618
std::string exec_path;
619619
if (uv_exepath(exec_path_buf, &exec_path_len) == 0) {
620620
exec_path = std::string(exec_path_buf, exec_path_len);
621-
} else {
621+
} else if (argv.size() > 0) {
622622
exec_path = argv[0];
623623
}
624624

0 commit comments

Comments
 (0)