diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2019-06-21 12:16:05 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-30 16:21:06 +0300 |
commit | 54ae5309513b3fa3b9ffa0e03faa70cf22a0bb90 (patch) | |
tree | 2ee63032f4a07cc1c623bab51e32de31942e146f /src/large_pages | |
parent | 89344f5bee0dc566e5990c9618efbb73d6a9284d (diff) |
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>
Diffstat (limited to 'src/large_pages')
-rw-r--r-- | src/large_pages/node_large_page.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/large_pages/node_large_page.cc b/src/large_pages/node_large_page.cc index 79cc013deef..e6829708aa0 100644 --- a/src/large_pages/node_large_page.cc +++ b/src/large_pages/node_large_page.cc @@ -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)) { |