Skip to content

Commit aec7ae2

Browse files
sam-githubMylesBorins
authored andcommitted
src: add SafeGetenv() to internal API
Allow it to be used anywhere in src/ that env variables with security implications are accessed. PR-URL: #11006 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent f2e97f8 commit aec7ae2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/node.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ Local<Value> UVException(Isolate* isolate,
945945

946946

947947
// Look up environment variable unless running as setuid root.
948-
inline bool SafeGetenv(const char* key, std::string* text) {
948+
bool SafeGetenv(const char* key, std::string* text) {
949949
#ifndef _WIN32
950950
// TODO(bnoordhuis) Should perhaps also check whether getauxval(AT_SECURE)
951951
// is non-zero on Linux.

src/node_internals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void RegisterSignalHandler(int signal,
112112
bool reset_handler = false);
113113
#endif
114114

115+
bool SafeGetenv(const char* key, std::string* text);
116+
115117
template <typename T, size_t N>
116118
constexpr size_t arraysize(const T(&)[N]) { return N; }
117119

0 commit comments

Comments
 (0)