Skip to content

Commit 276f3e6

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 <michael_dawson@ca.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent dc7cbf6 commit 276f3e6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/node.cc

+1-1
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

+2
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)