Skip to content

Commit 0dc1d85

Browse files
committed
src: add SafeGetenv() to internal API
Allow it to be used anywhere in src/ that env variables with security implications are accessed. PR-URL: nodejs#11006 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 6765c88 commit 0dc1d85

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
@@ -943,7 +943,7 @@ Local<Value> UVException(Isolate* isolate,
943943

944944

945945
// Look up environment variable unless running as setuid root.
946-
inline bool SafeGetenv(const char* key, std::string* text) {
946+
bool SafeGetenv(const char* key, std::string* text) {
947947
#ifndef _WIN32
948948
// TODO(bnoordhuis) Should perhaps also check whether getauxval(AT_SECURE)
949949
// 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)