Skip to content

Commit 95200ba

Browse files
authoredDec 20, 2022
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 8398f85 commit 95200ba

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)