mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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: https://github.com/nodejs/node/issues/45901 PR-URL: https://github.com/nodejs/node/pull/45902 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
7a97f3f43b
commit
574afac26a
1 file changed
+1
-1
+1
-1
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user