diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2020-02-04 17:52:39 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-02-08 01:49:18 +0300 |
commit | d394dd78de600e89ceea02b3582435e50f249aa4 (patch) | |
tree | 05ed92f334ac4b111c7af4911637da53ab57dbae /src/node_internals.h | |
parent | 7df429808ca336b6aa868a9ae1ceb6117c68e7c4 (diff) |
src: fix OOB reads in process.title getter
The getter passed a stack-allocated, fixed-size buffer to
uv_get_process_title() but neglected to check the return value.
When the total length of the command line arguments exceeds the size of
the buffer, libuv returns UV_ENOBUFS and doesn't modify the contents of
the buffer. The getter then proceeded to return whatever garbage was on
the stack at the time of the call, quite possibly reading beyond the
end of the buffer.
Add a GetProcessTitle() helper that reads the process title into a
dynamically allocated buffer that is resized when necessary.
Fixes: https://github.com/nodejs/node/issues/31631
PR-URL: https://github.com/nodejs/node/pull/31633
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_internals.h')
-rw-r--r-- | src/node_internals.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/node_internals.h b/src/node_internals.h index 55f5ac40ccc..abe01e6fed8 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -95,6 +95,7 @@ void ResetStdio(); // Safe to call more than once and from signal handlers. void SignalExit(int signal, siginfo_t* info, void* ucontext); #endif +std::string GetProcessTitle(const char* default_title); std::string GetHumanReadableProcessName(); void GetHumanReadableProcessName(char (*name)[1024]); |