src: readlink("/proc/self/exe") -> uv_exename()
This commit also adds error handling. A THP-enabled build terminated with an out-of-memory error on a system without /proc because it cast the -1 from readlink() to size_t (i.e. ULONG_MAX) and then tried to allocate a string of that size. PR-URL: https://github.com/nodejs/node/pull/28333 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
89344f5bee
commit
54ae530951
@ -115,8 +115,12 @@ static struct text_region FindNodeTextRegion() {
|
||||
std::string exename;
|
||||
{
|
||||
char selfexe[PATH_MAX];
|
||||
ssize_t count = readlink("/proc/self/exe", selfexe, PATH_MAX);
|
||||
exename = std::string(selfexe, count);
|
||||
|
||||
size_t size = sizeof(selfexe);
|
||||
if (uv_exepath(selfexe, &size))
|
||||
return nregion;
|
||||
|
||||
exename = std::string(selfexe, size);
|
||||
}
|
||||
|
||||
while (std::getline(ifs, map_line)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user